All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mework.roo.org.springframework.roo.addon.jpa.addon.2.0.0.M2.source-code.entities-and-entity-fields.roo Maven / Gradle / Ivy

The newest version!
# Create project, entities and fields to be able to test subsequent commands.
project setup --topLevelPackage aaa.bb.c.test
jpa setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY
entity jpa --class ~.domain.Entity1
entity jpa --class ~.domain.Entity2


#====================================================================================================================
# TEST 1: Create reference field with specific CascadeType.REFRESH
#--------------------------------------------------------------------------------------------------------------------
# Goal:   Test field reference command with the optional parameter --cascadeType
#
field reference --fieldName entity1_reference --type ~.domain.Entity1 --cardinality ONE_TO_ONE --cascadeType REFRESH
#      
# Output: Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity2.java
#         Created SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity2_Roo_JavaBean.aj
#
# Result: Create entity1_reference without errors and with @OneToOne(cascade = CascadeType.REFRESH)                                       
#====================================================================================================================


#====================================================================================================================
# TEST 2: Create set field with specific CascadeType.REMOVE
#--------------------------------------------------------------------------------------------------------------------
# Goal:   Test field set command with the optional parameter --cascadeType
#
field set --fieldName entity1_set --type ~.domain.Entity1 --cardinality ONE_TO_MANY --cascadeType REMOVE
#      
# Output: Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity2.java
#         Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity2_Roo_JavaBean.aj
#
# Result: Create entity1_reference without errors and with @OneToMany(cascade = CascadeType.REMOVE)                                        
#====================================================================================================================


#====================================================================================================================
# TEST 3: Create list field with specific CascadeType.PERSIST
#--------------------------------------------------------------------------------------------------------------------
# Goal:   Test field list command with the optional parameter --cascadeType
#
field list --fieldName entity1_list --type ~.domain.Entity1 --cardinality ONE_TO_MANY --cascadeType PERSIST
#      
# Output: Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity2.java
#         Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity2_Roo_JavaBean.aj
#
# Result: Create entity1_list without errors with and with @OneToMany(cascade = CascadeType.PERSIST)                                        
#====================================================================================================================


#====================================================================================================================
# TEST 4: Create reference field with default CascadeType (ALL)
#--------------------------------------------------------------------------------------------------------------------
# Goal:   Test field reference command with the default value of optional parameter --cascadeType
#
field reference --fieldName entity1_reference_default --type ~.domain.Entity1 --cardinality ONE_TO_ONE --cascadeType
#      
# Output: Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity2.java
#         Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity2_Roo_JavaBean.aj
#
# Result: Create entity1_reference without errors and with @OneToOne(cascade = CascadeType.ALL)                                
#====================================================================================================================


#====================================================================================================================
# TEST 5: Create set field with default CascadeType (ALL) without specifying it
#--------------------------------------------------------------------------------------------------------------------
# Goal:   Test field set command without the optional parameter --cascadeType
#
field set --fieldName entity1_set_unspecified --type ~.domain.Entity1 --cardinality ONE_TO_MANY
#      
# Output: Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity2.java
#         Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity2_Roo_JavaBean.aj
#
# Result: Create entity1_set_unspecified without errors and with @OneToMany(cascade = CascadeType.ALL)                              
#====================================================================================================================


#====================================================================================================================
# TEST 6: Create set field with default CascadeType (ALL)
#--------------------------------------------------------------------------------------------------------------------
# Goal:   Test field set command with the optional parameter --cascadeType, but without value.
#
field set --fieldName entity1_set_default --type ~.domain.Entity1 --cardinality ONE_TO_MANY --cascadeType
#      
# Output: Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity2.java
#         Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity2_Roo_JavaBean.aj
#
# Result: Create entity1_set_default without errors and with @OneToMany(cascade = CascadeType.ALL)                                
#====================================================================================================================


#====================================================================================================================
# TEST 7: Create String lob field
#--------------------------------------------------------------------------------------------------------------------
# Goal:   Test field string command with the optional parameter --lob
#
focus --class ~.domain.Entity1
field string --fieldName entity1_lob
#      
# Output: Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity1.java
#         Created SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity1_Roo_JavaBean.aj
#
# Result: Create entity1_lob field without errors and with @Lob and @Basic(fetch=LAZY)                       
#====================================================================================================================


#====================================================================================================================
# TEST 8: Create extended entity with identifier param using --force
#--------------------------------------------------------------------------------------------------------------------
# Goal:   Test entity jpa command with the optional parameter --extends and other identifier param, which will be 
#         overridden.
#
entity jpa --class ~.domain.Extended_Entity --extends ~.domain.Entity1 --identifierColumn id --force
#      
# Output: Created SRC_MAIN_JAVA/aaa/bbb/cc/domain/Extended_Entity.java
#         Created SRC_MAIN_JAVA/aaa/bbb/cc/domain/Extended_Entity_Roo_Jpa_Entity.aj
#         Created SRC_MAIN_JAVA/aaa/bbb/cc/domain/Extended_Entity_Roo_ToString.aj
#
# Result: Create Extended_Entity entity without errors but also without identifier field (it will use superclass 
#         identifier field).                      
#====================================================================================================================


#====================================================================================================================
# TEST 9: Create extended entity with version param using --force
#--------------------------------------------------------------------------------------------------------------------
# Goal:   Test entity jpa command with the optional parameter --extends and other version param, which will be 
#         overridden.
#
entity jpa --class ~.domain.Extended_Entity2 --extends ~.domain.Entity1 --versionField version --force
#      
# Output: Created SRC_MAIN_JAVA/aaa/bbb/cc/domain/Extended_Entity2.java
#         Created SRC_MAIN_JAVA/aaa/bbb/cc/domain/Extended_Entity2_Roo_Jpa_Entity.aj
#         Created SRC_MAIN_JAVA/aaa/bbb/cc/domain/Extended_Entity2_Roo_ToString.aj
#
# Result: Create Extended_Entity entity without errors but also without version field (it will use superclass 
#         version field).                                            
#====================================================================================================================


#====================================================================================================================
# TEST 10: Create field set with @JoinTable without value and without additional params
#--------------------------------------------------------------------------------------------------------------------
# Goal:   Test field set command with --joinTable param with default value (no value and no associate params).
#
focus --class ~.domain.Entity1
field set --fieldName set_field_join_table --type ~.domain.Extended_Entity2 --cardinality MANY_TO_MANY --joinTable
#      
# Output: Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity1.java
#         Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity1_Roo_JavaBean.aj
#
# Result: Create field set without errors containing @JoinTable       
#====================================================================================================================


#====================================================================================================================
# TEST 11: Create field set with OneToMany cardinality without @JoinTable
#--------------------------------------------------------------------------------------------------------------------
# Goal:   Test field set command without --joinTable param and with --cardinality ONE_TO_MANY
#
field set --fieldName set_field_join_table_name --type ~.domain.Extended_Entity2 --cardinality ONE_TO_MANY
#      
# Output: Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity1.java
#         Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity1_Roo_JavaBean.aj
#
# Result: Create field set without errors. OneToMany doesn't require @JoinTable                                         
#====================================================================================================================


#====================================================================================================================
# TEST 12: Create field set with @JoinTable with all its attributes
#--------------------------------------------------------------------------------------------------------------------
# Goal:   Test field set command with --joinTable param with value and all its associated attributes.
#
field set --fieldName set_field_complete_join_table --type ~.domain.Extended_Entity2 --cardinality MANY_TO_MANY --joinTable JOIN_TABLE --joinColumns COLUMN1_FK,COLUMN2_FK --referencedColumns COLUMN1,COLUMN2 --inverseJoinColumns INVERSE_COLUMN1_FK,INVERSE_COLUMN2_FK --inverseReferencedColumns INVERSE_COLUMN1,INVERSE_COLUMN2
#      
# Output: Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity1.java
#         Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity1_Roo_JavaBean.aj
#
# Result: Create field set without errors containing @JoinTable(name = "JOIN_TABLE", joinColumns = {...} 
#         inverseJoinColumns = {...})                                  
#====================================================================================================================


#====================================================================================================================
# TEST 13: Create field list with @JoinTable with all its attributes and default-specified cardinality
#--------------------------------------------------------------------------------------------------------------------
# Goal:   Test field list command with --joinTable param with value and all its associated attributes with default --cardinality (ONE_TO_MANY).
#
field list --fieldName list_field_complete_join_table --type ~.domain.Extended_Entity2 --cardinality --joinTable JOIN_TABLE --joinColumns COLUMN1_FK,COLUMN2_FK --referencedColumns COLUMN1,COLUMN2 --inverseJoinColumns INVERSE_COLUMN1_FK,INVERSE_COLUMN2_FK --inverseReferencedColumns INVERSE_COLUMN1,INVERSE_COLUMN2
#      
# Output: Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity1.java
#         Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity1_Roo_JavaBean.aj
#
# Result: Create field list without errors containing @JoinTable(name = "JOIN_TABLE", joinColumns = {...} 
#         inverseJoinColumns = {...})                                  
#====================================================================================================================


#====================================================================================================================
# TEST 14: Create field list with @JoinTable without value and without additional params
#--------------------------------------------------------------------------------------------------------------------
# Goal:   Test field list command with --joinTable param with default value (no value and no associate params).
#
field set --fieldName list_field_join_table --type ~.domain.Extended_Entity2 --cardinality MANY_TO_MANY --joinTable
#      
# Output: Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity1.java
#         Updated SRC_MAIN_JAVA/aaa/bbb/cc/domain/Entity1_Roo_JavaBean.aj
#
# Result: Create field list without errors containing @JoinTable       
#====================================================================================================================


##########################################################################
#######                      MANUAL TESTS                        #########
##########################################################################
#                                                                        #
# The following commands must be executed manually because they are      #
# supposed to interrupt script execution.                                #
#                                                                        #
##########################################################################


#====================================================================================================================
# TEST 15: Try to create set field with wrong CascadeType
#--------------------------------------------------------------------------------------------------------------------
# Goal:   Test field set command with the optional parameter --cascadeType with a wrong value.
#
#field set --fieldName entity1_wrong_cascade --type ~.domain.Entity1 --cardinality ONE_TO_MANY --cascadeType WRONG
#      
# Output: java.lang.IllegalArgumentException: Failed to convert 'WRONG' to type Cascade for option 'cascadeType'
#         No enum constant org.springframework.roo.classpath.operations.Cascade.WRONG
#
# Result: Throws and exception and stops command execution because the wrong enum value.                              
#====================================================================================================================


#====================================================================================================================
# TEST 16: Try to create extended entity with identifier param without using --force
#--------------------------------------------------------------------------------------------------------------------
# Goal:   Test entity jpa command with the optional parameter --extends and other identifier param.
#
#entity jpa --class ~.domain.Extended_Entity3 --extends ~.domain.Entity1 --identifierColumn id
#      
# Output: Identifier and version fields will be overwritten by superclass fields. Please, use --force to execute 
#         the command anyway
#
# Result: Command execution stops and user sees a warning message about the incompatible params.                      
#====================================================================================================================




© 2015 - 2025 Weber Informatics LLC | Privacy Policy