From: Vance K. <va...@us...> - 2006-03-16 15:26:26
|
User: vancek Date: 06/03/16 07:26:23 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: check for lob type when generating attribute types. @Transient annotation and all other annotations are mutually exclusive for attributes and associations. Revision Changes Path 1.22 +92 -57 cartridges/andromda-ejb3/src/main/resources/templates/ejb3/EntityEmbeddable.vsl Index: EntityEmbeddable.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/resources/templates/ejb3/EntityEmbeddable.vsl,v retrieving revision 1.21 retrieving revision 1.22 diff -u -w -r1.21 -r1.22 --- EntityEmbeddable.vsl 16 Mar 2006 02:08:34 -0000 1.21 +++ EntityEmbeddable.vsl 16 Mar 2006 15:26:23 -0000 1.22 @@ -102,10 +102,15 @@ // ----------- Attribute Definitions ------------ -#if ($entity.compositePrimaryKeyPresent) +## +## If composite PK attribute declaration +## +#**##if ($entity.compositePrimaryKeyPresent) private ${entity.fullyQualifiedEntityCompositePrimaryKeyName} pk; -#end +#**##end +## ## Only include identifier attributes if a composite primary key is NOT present +## #**##foreach ($attribute in $attributes) #* *##if ($entity.compositePrimaryKeyPresent && $attribute.identifier) #* *##set ($doAttribute = false) @@ -113,9 +118,13 @@ #* *##set ($doAttribute = true) #* *##end #* *##if ($doAttribute) - private ${attribute.type.fullyQualifiedName} $attribute.name; +## +## Check for overriding LOB type +## + private #if ($stringUtils.isNotBlank($attribute.lobType))${attribute.lobType}#else${attribute.type.fullyQualifiedName}#end $attribute.name; #* *##end #**##end + #end #set ($entityRelations = $entity.allEntityRelations) #if (!$entityRelations.empty) @@ -301,7 +310,10 @@ // -------- Attribute Accessors ---------- #**##foreach ($attribute in $attributes) -## Only include accessors for identifier attributes if entity does not have a composite primary key +## +## Only include accessors for identifier attributes if entity does not +## have a composite primary key +## #* *##if ($entity.compositePrimaryKeyPresent && $attribute.identifier) #* *##set ($doAttributeAccessors = false) #* *##else @@ -314,6 +326,12 @@ $attribute.getDocumentation(" * ") * @return $attribute.type.fullyQualifiedName The value of ${attribute.name} */ +## +## If attribute is transient ONLY add Transient annotation +## +#* *##if ($attribute.transient) + @javax.persistence.Transient +#* *##else #* *##if ($attribute.identifier) @javax.persistence.Id #* *##if ($attribute.sequenceGeneratorType) @@ -328,9 +346,6 @@ #* *##if ($attribute.version) @javax.persistence.Version #* *##end -#* *##if ($attribute.transient) - @javax.persistence.Transient -#* *##end #* *##if ($attribute.lob) ## ## Add if LOB type is specified - do not set LOB type as of PFD Spec - inferred from type. @@ -355,7 +370,11 @@ #* *##if ($stringUtils.isNotBlank($attribute.enumerationType)) @javax.persistence.Enumerated(javax.persistence.EnumType.${attribute.enumerationType}) #* *##end - public ${attribute.type.fullyQualifiedName} ${attribute.getterName}() +#* *##end +## +## Override attribute type if attribute is a LOB and lob type is specified +## + public #if ($stringUtils.isNotBlank($attribute.lobType))${attribute.lobType}#else${attribute.type.fullyQualifiedName}#end ${attribute.getterName}() { return $attribute.name; } @@ -368,7 +387,7 @@ * Set the $attribute.name property. * @param value the new value */ - #if (!$attribute.version) public#else protected#end void ${attribute.setterName}(${attribute.type.fullyQualifiedName} value) + #if (!$attribute.version) public#else protected#end void ${attribute.setterName}(#if ($stringUtils.isNotBlank($attribute.lobType))${attribute.lobType}#else${attribute.type.fullyQualifiedName}#end value) { this.${attribute.name} = value; } @@ -394,9 +413,12 @@ * * @return $target.getterSetterTypeName */ +## +## If target association is transient ONLY add Transient annotation +## #* *##if ($target.transient) @javax.persistence.Transient -#* *##end +#* *##else #* *##set ($argExists = false) @javax.persistence.ManyToOne(#if (!$target.optional)optional = false#set ($argExists = true)#end#if ($target.cascadeType)#if ($argExists), #end#**#cascade = {${target.cascadeType}}#set ($argExists = true)#end#if ($target.lazy)#if ($argExists), #end#**#fetch = javax.persistence.FetchType.LAZY#end) ## @@ -415,6 +437,7 @@ #* *##end }) #* *##end +#* *##end public $target.getterSetterTypeName ${target.getterName}() { return this.${target.name}; @@ -445,9 +468,12 @@ * * @return $target.getterSetterTypeName */ +## +## If target association is transient ONLY add Transient annotation +## #* *##if ($target.transient) @javax.persistence.Transient -#* *##end +#* *##else #* *##set ($argExists = false) @javax.persistence.OneToMany(#if ($target.cascadeType)cascade = {${target.cascadeType}}#set ($argExists = true)#end#if ($associationEnd.navigable)#if ($argExists) ,#end#**#mappedBy = "${associationEnd.name}"#set ($argExists = true)#end#if ($target.eager)#if ($argExists), #end#**#fetch = javax.persistence.FetchType.EAGER#end) #* *##if ($target.hasTaggedValue("@andromda.persistence.orderBy")) @@ -460,6 +486,7 @@ #* *##if ($target.associationCacheEnabled) @org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.${target.cacheType}) #* *##end +#* *##end public $target.getterSetterTypeName ${target.getterName}() { return this.${target.name}; @@ -487,9 +514,12 @@ * * @return $target.getterSetterTypeName */ +## +## If target association is transient ONLY add Transient annotation +## #* *##if ($target.transient) @javax.persistence.Transient -#* *##end +#* *##else #* *##set ($argExists = false) @javax.persistence.OneToOne(#if($associationEnd.owning)#if (!$target.optional)optional = false#set ($argExists = true)#end#end#if ($target.cascadeType)#if ($argExists), #end#**#cascade = {${target.cascadeType}}#set ($argExists = true)#end#if(!$associationEnd.owning)#if ($argExists), #end#**#mappedBy = "${associationEnd.name}"#set ($argExists = true)#end#if ($target.lazy)#if ($argExists), #end#**#fetch = javax.persistence.FetchType.LAZY#end) #* *##if($associationEnd.owning) @@ -510,6 +540,7 @@ }) #* *##end #* *##end +#* *##end public $target.getterSetterTypeName ${target.getterName}() { return this.${target.name}; @@ -538,9 +569,12 @@ * * @return $target.getterSetterTypeName */ +## +## If target association is transient ONLY add Transient annotation +## #* *##if ($target.transient) @javax.persistence.Transient -#* *##end +#* *##else #* *##set ($argExists = false) @javax.persistence.ManyToMany(#if ($target.cascadeType)cascade = {${target.cascadeType}}#set ($argExists = true)#end#if(!$associationEnd.owning)#if ($argExists), #end#**#mappedBy = "${associationEnd.name}"#set ($argExists = true)#end#if ($target.eager)#if ($argExists), #end#**#fetch = javax.persistence.FetchType.EAGER#end) ## Use Aggregation and Composition to determine owning side @@ -567,6 +601,7 @@ #* *##if ($target.associationCacheEnabled) @org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.${target.cacheType}) #* *##end +#* *##end public $target.getterSetterTypeName ${target.getterName}() { return this.${target.name}; |