From: Vance K. <va...@us...> - 2006-01-17 04:11:28
|
User: vancek Date: 06/01/16 20:11:21 Added: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: initial revision - this is the abstract entity base class Revision Changes Path 1.1 cartridges/andromda-ejb3/src/main/resources/templates/ejb3/EntityEmbeddable.vsl Index: EntityEmbeddable.vsl =================================================================== // license-header java merge-point /* Autogenerated by AndroMDA (Entity.vsl) - do not edit */ #if ($stringUtils.isNotBlank($entity.packageName)) package $entity.packageName; #end #set ($generatedFile = "${stringUtils.replace($entity.fullyQualifiedEntityEmbeddableName,'.','/')}.java") #set ($identifier = $entity.identifiers.iterator().next()) /** * Autogenerated POJO EJB3 super class for ${entity.entityName} containing the * bulk of the entity implementation. * * This is an embeddable super class and autogenerated by AndroMDA using the EJB3 * cartridge. * * DO NOT MODIFY this class. * $entity.getDocumentation(" * ") * */ @javax.persistence.EmbeddableSuperclass#if ($entity.accessType)(access = javax.persistence.AccessType.${entity.accessType})#end @javax.persistence.EntityListener(${entity.fullyQualifiedEntityListenerName}.class) @javax.persistence.Table(name = "${entity.tableName}") #if ($entity.requiresSpecializationMapping) @javax.persistence.Inheritance(strategy = javax.persistence.InheritanceType.${entity.inheritanceStrategy}, discriminatorType = javax.persistence.DiscriminatorType.${entity.discriminatorType}#if ($entity.discriminatorValue), discriminatorValue = "${entity.discriminatorValue}"#end) #**##if ($entity.inheritanceSingleTable || $entity.inheritanceJoined) @javax.persistence.DiscriminatorColumn(name = "${entity.discriminatorColumn}"#if ($entity.discriminatorColumnDefinition), columnDefinition = "${entity.discriminatorColumnDefinition}"#end#if ($entity.discriminatorLength > 0), length = ${entity.discriminatorLength}#end) #**##end #elseif ($entity.requiresGeneralizationMapping) @javax.persistence.Inheritance#if ($entity.discriminatorValue)(discriminatorValue = "${entity.discriminatorValue}")#end #end public abstract class ${entity.entityEmbeddableName} #if($entity.generalization) extends ${entity.generalization.fullyQualifiedName} #end implements java.io.Serializable { private static final long serialVersionUID = ${entity.serialVersionUID}L; #set ($constants = $entity.getConstants(true)) #if (!$constants.empty) // ----------- Constant Definitions ------------- #**##foreach($constant in $constants) @javax.persistence.Transient private static final $constant.type.fullyQualifiedName $constant.name = $constant.defaultValue; #**##end #end #set ($attributes = $entity.attributes) #if (!$attributes.empty) // ----------- Attribute Definitions ------------ #**##foreach ($attribute in $attributes) private $attribute.type.fullyQualifiedName $attribute.name; #**##end #end #set ($entityRelations = $entity.allEntityRelations) #if (!$entityRelations.empty) // --------- Relationship Definitions ----------- #**##foreach ($associationEnd in $entityRelations) #**##**##if ($associationEnd.one2Many || $associationEnd.many2Many) private $associationEnd.relationType<${associationEnd.otherEnd.type.name}> ${associationEnd.otherEnd.name}; #**##**##else private $associationEnd.relationType ${associationEnd.otherEnd.name}; #**##**##end #**##end #end // --------------- Constructors ----------------- /** * Default empty constructor */ public ${entity.entityEmbeddableName}() { // default null constructor } ## Autogenerate a constructor implementation with all attributes. #set ($allAttributes = $transform.filterByVisibility($entity.allInstanceAttributes, "public")) #set ($inheritedAttributes = $transform.filterByVisibility($entity.inheritedInstanceAttributes, "public")) #set ($instanceAttributes = $transform.filterByVisibility($entity.instanceAttributes, "public")) /** * Implementation for the main constructor with all POJO attributes. * This method sets all POJO fields defined in this class to the * values provided by the parameters. * #foreach($attribute in $transform.filterUpdatableAttributes($allAttributes)) * @param $attribute.name Value for the ${attribute.name} property #end */ public ${entity.entityEmbeddableName}($entity.getAttributesAsList($allAttributes, true, true)) { #if(!$inheritedAttributes.empty) super($entity.getAttributesAsList($inheritedAttributes, false, true)); #end #foreach ($attribute in $transform.filterUpdatableAttributes($instanceAttributes)) ${attribute.setterName}(${attribute.name}); #end } #set ($relations = $entity.allEntityRelations) #if (!$relations.empty) #**##if ($entity.syntheticCreateMethodAllowed) /** * Constructor with all POJO attribute values and CMR relations. #* *##foreach($attribute in $allAttributes) * @param $attribute.name Value for the $attribute.name property #* *##end #* *##foreach ($relation in $relations) * @param $relation.otherEnd.name Value for the ${relation.otherEnd.name} relation role #* *##end */ public ${entity.entityEmbeddableName}($entity.getAttributesAsList($allAttributes, true, true)#if(!$allAttributes.empty), #end#foreach ($relation in $relations)#if ($relation.one2Many || $relation.many2Many)${relation.relationType}<${relation.otherEnd.type.name}> $relation.otherEnd.name#else${relation.relationType} $relation.otherEnd.name#end#if($velocityCount != $relations.size()), #end#end) { // Call suitable class constructor this($entity.getAttributesAsList($allAttributes, false, true)); // Set the CMR relations #* *##foreach ($relation in $relations) ${relation.otherEnd.setterName}($relation.otherEnd.name); #* *##end } #**##end #end #foreach ($operation in $entity.getCreateMethods(true)) #**##set ($opArguments = $transform.getArgumentsAsList(${operation.argumentNames})) /** * Explicitly defined constuctor with specified args list. $operation.getDocumentation(" * ") #**##foreach($attribute in $opArguments) * @param $attribute Value for the $attribute property #**##end */ public ${entity.entityEmbeddableName}(${operation.typedArgumentList}) { #**##foreach($attribute in $opArguments) this.${attribute} = $attribute; #**##end } #end #if (!$constants.empty) // --------- Constant Accessors ---------- #**##foreach($constant in $constants) /** * Get the <code>$constant.name</code> constant $constant.getDocumentation(" * ") * $constant.visibility $constant.type.fullyQualifiedName ${constant.getterName}() { return $constant.name; } #**##end #end #if (!$attributes.empty) // -------- Attribute Accessors ---------- #**##foreach ($attribute in $entity.attributes) #* *##set ($visibility = $attribute.visibility) /** * Get the $attribute.name property. $attribute.getDocumentation(" * ") * @return $attribute.type.fullyQualifiedName The value of ${attribute.name} */ #* *##if ($attribute.identifier) #* *##if ($attribute.sequenceGeneratorType || $attribute.tableGeneratorType) @javax.persistence.TableGenerator(name = "${attribute.generatorName}"#if ($attribute.sequenceGeneratorType), sequenceName = "${attribute.generatorSourceName}"#elseif ($attribute.tableGeneratorType), tableName = "${attribute.generatorSourceName}"#end,#if ($attribute.tableGeneratorType) pkColumnValue = "${attribute.generatorPkColumnValue}",#end#if ($attribute.sequenceGeneratorType) initialValue = ${attribute.generatorInitialValue},#end allocationSize = ${attribute.generatorAllocationSize}) #* *##end @javax.persistence.Id(generate = javax.persistence.GeneratorType.${attribute.generatorType}#if ($attribute.sequenceGeneratorType || $attribute.tableGeneratorType), generator = "${attribute.generatorName}"#end) #* *##end #* *##if ($attribute.version) @javax.persistence.Version #* *##end #* *##if ($attribute.transient) @javax.persistence.Transient #* *##end #* *##if ($attribute.lobType) ## LOB type is specified - also sepcify FetchType if set to EAGER since default fetch type for LOB annotation is LAZY @javax.persistence.Lob(type = javax.persistence.LobType.${attribute.lobType}#if ($attribute.eager), fetch = javax.persistence.FetchType.EAGER#end) #* *##end @javax.persistence.Column(name = "${attribute.columnName}"#if ($attribute.unique), unique = ${attribute.unique}#end#if (!$attribute.columnNullable), nullable = ${attribute.columnNullable}#end#if ($attribute.columnLength), length = ${attribute.columnLength}#end#if ($attribute.columnDefinition), columnDefinition = "${attribute.columnDefinition}"#end#if ($attribute.columnPrecision), precision = ${attribute.columnPrecision}#end#if ($attribute.columnScale), scale = ${attribute.columnScale}#end) ## Only add the fetch type property for LAZY hints - default is EAGER #* *##if ($attribute.lazy) @javax.persistence.Basic(fetch = javax.persistence.FetchType.LAZY) #* *##end public $attribute.type.fullyQualifiedName ${attribute.getterName}() { return $attribute.name; } ## Allow only if not a version attribute since they are set by the container - No setter method is made available /** * Set the $attribute.name property. * @param value the new value */ #if (!$attribute.version) public#else protected#end void ${attribute.setterName}($attribute.type.fullyQualifiedName value) { this.${attribute.name} = value; } #**##end #end // ------------- Relations ------------------ #foreach ($associationEnd in $entity.allEntityRelations) #**##set ($target = $associationEnd.otherEnd) #**##if($target.navigable) #* *##if ($associationEnd.many2One) ## ## MANY TO ONE RELATIONSHIP ## ## Default fetch type: EAGER ## /** * Get the ${target.name} * @return $associationEnd.relationType */ #* *##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) @javax.persistence.JoinColumn(name = "$stringUtils.upperCase(${target.name})"#if ($associationEnd.columnDefinition), columnDefinition = "${associationEnd.columnDefinition}"#end) public $associationEnd.relationType ${target.getterName}() { return this.${target.name}; } #* *##if(!$target.readOnly) /** * Set the ${target.name} * @param ${target.name} */ public void ${target.setterName}($associationEnd.relationType ${target.name}) { this.${target.name} = ${target.name}; } #* *##end #* *##elseif ($associationEnd.one2Many) ## ## ONE TO MANY RELATIONSHIP ## ## Include the mappedBy element for bidirection relationships ONLY ## Default fetch type: LAZY ## If orderBy element is not specified, container assumes PK ordering ## /** * Get the ${target.name} Collection * @return $associationEnd.relationType */ #* *##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")) #* *##if ($stringUtils.isNotEmpty(${target.orderByClause})) @javax.persistence.OrderBy("${target.orderByClause}") #* *##else @javax.persistence.OrderBy #* *##end #* *##end public $associationEnd.relationType<${target.type.name}> ${target.getterName}() { return this.${target.name}; } /** * Set the ${target.name} * @param ${target.name} */ public void ${target.setterName} (${associationEnd.relationType}<${target.type.name}> ${target.name}) { this.${target.name} = ${target.name}; } #* *##elseif ($associationEnd.one2One) ## ## ONE TO ONE RELATIONSHIP ## ## Default fetch type: EAGER ## /** * Get the ${target.name} * @return $associationEnd.relationType */ #* *##set ($argExists = false) @javax.persistence.OneToOne(#if (!$target.optional)optional = false#set ($argExists = true)#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) @javax.persistence.JoinColumn(name = "$stringUtils.upperCase(${target.name})"#if ($associationEnd.columnDefinition), columnDefinition = "${associationEnd.columnDefinition}"#end) #* *##end public $associationEnd.relationType ${target.getterName}() { return this.${target.name}; } #* *##if(!$target.readOnly) /** * Set the ${target.name} * @param ${target.name} */ public void ${target.setterName}($associationEnd.relationType ${target.name}) { this.${target.name} = ${target.name}; } #* *##end #* *##elseif ($associationEnd.many2Many) ## ## MANY TO MANY RELATIONSHIP ## ## Default fetch type: LAZY ## /** * Get the ${target.name} Collection * @return $associationEnd.relationType */ #* *##set ($argExists = false) @javax.persistence.ManyToMany(#if ($target.cascadeType)cascade = {${target.cascadeType}}#set ($argExists = true)#end#if ($target.eager)#if ($argExists), #end#**#fetch = javax.persistence.FetchType.EAGER#end) ## Use Aggregation and Composition to determine owning side #* *##if(($associationEnd.owning) && ${associationEnd.association.tableName}) @javax.persistence.JoinTable(table = @javax.persistence.Table(name = "${associationEnd.association.tableName}")) #* *##end #* *##if ($target.hasTaggedValue("@andromda.persistence.orderBy")) #* *##if ($stringUtils.isNotEmpty(${target.orderByClause})) @javax.persistence.OrderBy("${target.orderByClause}") #* *##else @javax.persistence.OrderBy #* *##end #* *##end public $associationEnd.relationType<${target.type.name}> ${target.getterName}() { return this.${target.name}; } /** * Set the ${target.name} * @param ${target.name} */ public void ${target.setterName} (${associationEnd.relationType}<${target.type.name}> ${target.name}) { this.${target.name} = ${target.name}; } #* *##end #**##end #end #if ($entity.genericFinders) // ----------- Generic Finder Methods -------------- /** * Returns the collection of all ${entity.name}s. * * @param em javax.persistence.EntityManager * @return all available ${entity.name} objects */ public static java.util.Collection<${entity.name}> findAll(javax.persistence.EntityManager em) { return em.createQuery("FROM ${entity.tableName} AS $stringUtils.uncapitalize(${entity.name})").getResultList(); } #**##foreach ($attribute in $entity.attributes) #* *##if ($attribute.identifier) #* *##set ($identifierName = $attribute.name) #* *##set ($identifierType = $attribute.type.fullyQualifiedName) #* *##set ($identifierTypeWrapperName = $attribute.type.wrapperName) #* *##end #**##end /** * Returns the ${entity.name} matching the identifier. * * @param em javax.persistence.EntityManager * @param ${identifierName} the primary key * @return the ${entity.name} object matching the primary key */ public static ${entity.fullyQualifiedEntityName} findByPrimaryKey(javax.persistence.EntityManager em, ${identifierType} ${identifierName}) { ## Identifier will always be a primitive type return em.find(${entity.fullyQualifiedEntityName}.class, new ${identifierTypeWrapperName}(${identifierName})); } #end #set ($finders = $entity.getQueryOperations(true)) #if (!$finders.empty) // -------- User Defined Finder Methods ------------ #**##foreach ($finder in $finders) #* *##set ($returnType = $finder.returnType.fullyQualifiedName) #* *##set ($parameterList = $finder.typedArgumentList) #* *##if ($finder.arguments.empty) #* *##set ($parameters = "javax.persistence.EntityManager em") #* *##else #* *##set ($parameters = "javax.persistence.EntityManager em, ${parameterList}") #* *##end /** $finder.getDocumentation(" * ") * * Finder method for ${entity.name} entity using a query. * @param em javax.persistence.EntityManager #* *##foreach ($parameter in $finder.arguments) * @param $parameter.type.fullyQualifiedName ${parameter.name} #* *##end * @return $returnType */ $finder.visibility static $returnType#if ($returnType == "java.util.Collection" || $returnType == "java.util.List")<${entity.name}>#end ${finder.name}($parameters) { javax.persistence.Query query = em.createQuery("$finder.query"); #* *##foreach ($parameter in $finder.arguments) #* *##set ($index = $velocityCount - 1) #* *##if ($parameter.firstResult) query.setFirstResult(${parameter.name}); #* *##elseif ($parameter.maxResults) query.setMaxResults(${parameter.name}); #* *##else #* *##if ($finder.useNamedParameters) query.setParameter("${parameter.name}",#if ($parameter.type.primitive) new ${parameter.type.wrapperName}(${parameter.name})#else ${parameter.name}#end#if ($parameter.temporalType), javax.persistence.TemporalType.${parameter.temporalType}#end); #* *##else query.setParameter(${index},#if ($parameter.type.primitive) new ${parameter.type.wrapperName}(${parameter.name})#else ${parameter.name}#end#if ($parameter.temporalType), javax.persistence.TemporalType.${parameter.temporalType}#end); #* *##end #* *##end #* *##end #* *##if ($finder.returnType.primitive) return (($finder.returnType.wrapperName)query.getSingleResult()).${returnType}Value(); #* *##elseif (!$finder.returnType.collectionType) return ($returnType)query.getSingleResult(); #* *##else return query.getResultList(); #* *##end } #**##end #end #set ($businessOperations = $entity.businessOperations) #if (!$businessOperations.empty) // --------------- Business Methods ----------------- #**##foreach ($operation in ) #* *##set ($signature = $operation.signature) #* *##set ($visibility = $operation.visibility.toString()) /** $operation.getDocumentation(" * ") */ #* *##set ($returnType = $operation.returnType.fullyQualifiedName) #* *##if ($operation.exceptionsPresent) $visibility abstract $returnType $signature throws $operation.exceptionList; #* *##else $visibility abstract $returnType $signature; #* *##end #**##end #end } |
From: Vance K. <va...@us...> - 2006-01-18 08:48:48
|
User: vancek Date: 06/01/18 00:48:42 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: introduced composite primary key, fixed findByPrimaryKey for non-primitive types Revision Changes Path 1.2 +89 -29 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.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- EntityEmbeddable.vsl 17 Jan 2006 04:11:21 -0000 1.1 +++ EntityEmbeddable.vsl 18 Jan 2006 08:48:42 -0000 1.2 @@ -55,9 +55,20 @@ // ----------- Attribute Definitions ------------ +#if ($entity.compositePrimaryKeyPresent) + private ${entity.fullyQualifiedEntityCompositePrimaryKeyName} pk; +#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) +#* *##else +#* *##set ($doAttribute = true) +#* *##end +#* *##if ($doAttribute) private $attribute.type.fullyQualifiedName $attribute.name; #**##end +#**##end #end #set ($entityRelations = $entity.allEntityRelations) #if (!$entityRelations.empty) @@ -87,22 +98,21 @@ #set ($allAttributes = $transform.filterByVisibility($entity.allInstanceAttributes, "public")) #set ($inheritedAttributes = $transform.filterByVisibility($entity.inheritedInstanceAttributes, "public")) #set ($instanceAttributes = $transform.filterByVisibility($entity.instanceAttributes, "public")) - /** * Implementation for the main constructor with all POJO attributes. * This method sets all POJO fields defined in this class to the * values provided by the parameters. * -#foreach($attribute in $transform.filterUpdatableAttributes($allAttributes)) +#foreach($attribute in $transform.filterUpdatableAttributes($allAttributes, $entity.compositePrimaryKeyPresent)) * @param $attribute.name Value for the ${attribute.name} property #end */ - public ${entity.entityEmbeddableName}($entity.getAttributesAsList($allAttributes, true, true)) + public ${entity.entityEmbeddableName}($entity.getAttributesAsList($allAttributes, true, true, false)) { #if(!$inheritedAttributes.empty) - super($entity.getAttributesAsList($inheritedAttributes, false, true)); + super($entity.getAttributesAsList($inheritedAttributes, false, true, false)); #end -#foreach ($attribute in $transform.filterUpdatableAttributes($instanceAttributes)) +#foreach ($attribute in $transform.filterUpdatableAttributes($instanceAttributes, $entity.compositePrimaryKeyPresent)) ${attribute.setterName}(${attribute.name}); #end } @@ -119,10 +129,10 @@ * @param $relation.otherEnd.name Value for the ${relation.otherEnd.name} relation role #* *##end */ - public ${entity.entityEmbeddableName}($entity.getAttributesAsList($allAttributes, true, true)#if(!$allAttributes.empty), #end#foreach ($relation in $relations)#if ($relation.one2Many || $relation.many2Many)${relation.relationType}<${relation.otherEnd.type.name}> $relation.otherEnd.name#else${relation.relationType} $relation.otherEnd.name#end#if($velocityCount != $relations.size()), #end#end) + public ${entity.entityEmbeddableName}($entity.getAttributesAsList($allAttributes, true, true, false)#if(!$allAttributes.empty), #end#foreach ($relation in $relations)#if ($relation.one2Many || $relation.many2Many)${relation.relationType}<${relation.otherEnd.type.name}> $relation.otherEnd.name#else${relation.relationType} $relation.otherEnd.name#end#if($velocityCount != $relations.size()), #end#end) { // Call suitable class constructor - this($entity.getAttributesAsList($allAttributes, false, true)); + this($entity.getAttributesAsList($allAttributes, false, true, false)); // Set the CMR relations #* *##foreach ($relation in $relations) @@ -147,6 +157,19 @@ this.${attribute} = $attribute; #**##end } + +#end +#if ($entity.compositePrimaryKeyPresent) + /** + * Constructor with composite primary key arg only + * + * @param pk Composite primary key + */ + public ${entity.entityEmbeddableName}(${entity.fullyQualifiedEntityCompositePrimaryKeyName} pk) + { + this.pk = pk; + } + #end #if (!$constants.empty) @@ -161,13 +184,47 @@ { return $constant.name; } + #**##end #end +#if ($entity.compositePrimaryKeyPresent) + + // ----- Composite PK Accessors ------ + + /** + * Return the composite primary key for ${entity.entityName} + * + * @return The composite primary key + */ + @javax.persistence.EmbeddedId + public ${entity.fullyQualifiedEntityCompositePrimaryKeyName} getPk() + { + return this.pk; + } + + /** + * Set the composite primary key for ${entity.entityName} + * + * @param pk The composite primary key + */ + public void setPk(${entity.fullyQualifiedEntityCompositePrimaryKeyName} pk) + { + this.pk = pk; + } + +#end #if (!$attributes.empty) // -------- Attribute Accessors ---------- #**##foreach ($attribute in $entity.attributes) +## Only include accessors for identifier attributes if entity does not have a composite primary key +#* *##if ($entity.compositePrimaryKeyPresent && $attribute.identifier) +#* *##set ($doAttributeAccessors = false) +#* *##else +#* *##set ($doAttributeAccessors = true) +#* *##end +#* *##if ($doAttributeAccessors) #* *##set ($visibility = $attribute.visibility) /** * Get the $attribute.name property. @@ -211,6 +268,7 @@ } #**##end +#**##end #end // ------------- Relations ------------------ @@ -363,11 +421,12 @@ { return em.createQuery("FROM ${entity.tableName} AS $stringUtils.uncapitalize(${entity.name})").getResultList(); } - -#**##foreach ($attribute in $entity.attributes) -#* *##if ($attribute.identifier) +#**##if (!$entity.compositePrimaryKeyPresent) +#**##foreach ($attribute in $entity.getIdentifiers(false)) #* *##set ($identifierName = $attribute.name) #* *##set ($identifierType = $attribute.type.fullyQualifiedName) +#* *##set ($identifierTypePrimitive = $attribute.type.primitive) +#* *##if ($attribute.type.primitive) #* *##set ($identifierTypeWrapperName = $attribute.type.wrapperName) #* *##end #**##end @@ -380,9 +439,10 @@ */ public static ${entity.fullyQualifiedEntityName} findByPrimaryKey(javax.persistence.EntityManager em, ${identifierType} ${identifierName}) { -## Identifier will always be a primitive type - return em.find(${entity.fullyQualifiedEntityName}.class, new ${identifierTypeWrapperName}(${identifierName})); +## If the identifier is a primitive type, use the wrapper class + return em.find(${entity.fullyQualifiedEntityName}.class,#if ($identifierTypePrimitive) new ${identifierTypeWrapperName}(${identifierName})#else ${identifierName}#end); } +#**##end #end #set ($finders = $entity.getQueryOperations(true)) #if (!$finders.empty) |
From: Vance K. <va...@us...> - 2006-01-19 06:48:46
|
User: vancek Date: 06/01/18 22:48:40 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: based on the entity inheritance hierarchy: adjust generatedFile switch EmbeddableSuperclass / Entity annotations switch class/consturctor names accordingly include generic finders accordingly Revision Changes Path 1.3 +53 -20 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.2 retrieving revision 1.3 diff -u -w -r1.2 -r1.3 --- EntityEmbeddable.vsl 18 Jan 2006 08:48:42 -0000 1.2 +++ EntityEmbeddable.vsl 19 Jan 2006 06:48:40 -0000 1.3 @@ -3,14 +3,26 @@ #if ($stringUtils.isNotBlank($entity.packageName)) package $entity.packageName; #end -#set ($generatedFile = "${stringUtils.replace($entity.fullyQualifiedEntityEmbeddableName,'.','/')}.java") +## +## If the entity is in the middle of an inheritance hierarchy +## it cannot be: +## +## 1. an embeddable superclass +## 2. an abstract class +## +## +#if (!$entity.requiresGeneralizationMapping) +#**##set ($generatedFile = "${stringUtils.replace($entity.fullyQualifiedEntityEmbeddableName,'.','/')}.java") +#else +#**##set ($generatedFile = "${stringUtils.replace($entity.fullyQualifiedEntityName,'.','/')}.java") +#end #set ($identifier = $entity.identifiers.iterator().next()) /** - * Autogenerated POJO EJB3 super class for ${entity.entityName} containing the + * Autogenerated POJO EJB #if (!$entity.requiresGeneralizationMapping) super#end class for ${entity.entityName} containing the * bulk of the entity implementation. * - * This is an embeddable super class and autogenerated by AndroMDA using the EJB3 + * This is#if (!$entity.requiresGeneralizationMapping) an embeddable super class and#end autogenerated by AndroMDA using the EJB3 * cartridge. * * DO NOT MODIFY this class. @@ -18,11 +30,19 @@ $entity.getDocumentation(" * ") * */ - +#if (!$entity.requiresGeneralizationMapping) @javax.persistence.EmbeddableSuperclass#if ($entity.accessType)(access = javax.persistence.AccessType.${entity.accessType})#end +#else +...@ja...rsistence.Entity#if ($entity.accessType)(access = javax.persistence.AccessType.${entity.accessType})#end + +#end @javax.persistence.EntityListener(${entity.fullyQualifiedEntityListenerName}.class) +## Include the Table annotation for a base class in inheritence hierarchy +## if but not the inheriting classes. +#if (!$entity.requiresGeneralizationMapping) @javax.persistence.Table(name = "${entity.tableName}") +#end #if ($entity.requiresSpecializationMapping) @javax.persistence.Inheritance(strategy = javax.persistence.InheritanceType.${entity.inheritanceStrategy}, discriminatorType = javax.persistence.DiscriminatorType.${entity.discriminatorType}#if ($entity.discriminatorValue), discriminatorValue = "${entity.discriminatorValue}"#end) #**##if ($entity.inheritanceSingleTable || $entity.inheritanceJoined) @@ -32,7 +52,8 @@ @javax.persistence.Inheritance#if ($entity.discriminatorValue)(discriminatorValue = "${entity.discriminatorValue}")#end #end -public abstract class ${entity.entityEmbeddableName} +public#if (!$entity.requiresGeneralizationMapping) abstract class ${entity.entityEmbeddableName}#else class ${entity.entityName}#end + #if($entity.generalization) extends ${entity.generalization.fullyQualifiedName} #end @@ -89,7 +110,7 @@ /** * Default empty constructor */ - public ${entity.entityEmbeddableName}() + public #if (!$entity.requiresGeneralizationMapping)${entity.entityEmbeddableName}#else${entity.entityName}#end() { // default null constructor } @@ -107,7 +128,7 @@ * @param $attribute.name Value for the ${attribute.name} property #end */ - public ${entity.entityEmbeddableName}($entity.getAttributesAsList($allAttributes, true, true, false)) + public #if (!$entity.requiresGeneralizationMapping)${entity.entityEmbeddableName}#else${entity.entityName}#end($entity.getAttributesAsList($allAttributes, true, true, false)) { #if(!$inheritedAttributes.empty) super($entity.getAttributesAsList($inheritedAttributes, false, true, false)); @@ -129,7 +150,7 @@ * @param $relation.otherEnd.name Value for the ${relation.otherEnd.name} relation role #* *##end */ - public ${entity.entityEmbeddableName}($entity.getAttributesAsList($allAttributes, true, true, false)#if(!$allAttributes.empty), #end#foreach ($relation in $relations)#if ($relation.one2Many || $relation.many2Many)${relation.relationType}<${relation.otherEnd.type.name}> $relation.otherEnd.name#else${relation.relationType} $relation.otherEnd.name#end#if($velocityCount != $relations.size()), #end#end) + public #if (!$entity.requiresGeneralizationMapping)${entity.entityEmbeddableName}#else${entity.entityName}#end($entity.getAttributesAsList($allAttributes, true, true, false)#if(!$allAttributes.empty), #end#foreach ($relation in $relations)#if ($relation.one2Many || $relation.many2Many)${relation.relationType}<${relation.otherEnd.type.name}> $relation.otherEnd.name#else${relation.relationType} $relation.otherEnd.name#end#if($velocityCount != $relations.size()), #end#end) { // Call suitable class constructor this($entity.getAttributesAsList($allAttributes, false, true, false)); @@ -151,7 +172,7 @@ * @param $attribute Value for the $attribute property #**##end */ - public ${entity.entityEmbeddableName}(${operation.typedArgumentList}) + public #if (!$entity.requiresGeneralizationMapping)${entity.entityEmbeddableName}#else${entity.entityName}#end(${operation.typedArgumentList}) { #**##foreach($attribute in $opArguments) this.${attribute} = $attribute; @@ -165,7 +186,7 @@ * * @param pk Composite primary key */ - public ${entity.entityEmbeddableName}(${entity.fullyQualifiedEntityCompositePrimaryKeyName} pk) + public #if (!$entity.requiresGeneralizationMapping)${entity.entityEmbeddableName}#else${entity.entityName}#end(${entity.fullyQualifiedEntityCompositePrimaryKeyName} pk) { this.pk = pk; } @@ -411,17 +432,29 @@ // ----------- Generic Finder Methods -------------- +## Do not include the findAll finder for inheriting classes when the +## inheritance strategy is single table. This is defined in the base +## class. +#**##if (($entity.inheritanceSingleTable && !$entity.requiresGeneralizationMapping) || !$entity.inheritanceSingleTable) /** * Returns the collection of all ${entity.name}s. * * @param em javax.persistence.EntityManager * @return all available ${entity.name} objects */ - public static java.util.Collection<${entity.name}> findAll(javax.persistence.EntityManager em) +## For inheriting classes, replace findAll with findAll${entity.name}s + public static java.util.Collection<${entity.name}> findAll#if ($entity.requiresGeneralizationMapping)$stringUtils.capitalize(${entity.name})s#end(javax.persistence.EntityManager em) { return em.createQuery("FROM ${entity.tableName} AS $stringUtils.uncapitalize(${entity.name})").getResultList(); } -#**##if (!$entity.compositePrimaryKeyPresent) +#**##end +## Only include the findByPrimaryKey method if not an inheriting class. +## Classes that inherit from a base class use the primary key identifier +## of the base class. The inheritence relationship is reflected in the +## queries, so queries based on the base/root class are polymorphic. +## Do not include the findByPrimaryKey if this bean has a composite +## primary key class. +#**##if (!$entity.compositePrimaryKeyPresent && !$entity.requiresGeneralizationMapping) #**##foreach ($attribute in $entity.getIdentifiers(false)) #* *##set ($identifierName = $attribute.name) #* *##set ($identifierType = $attribute.type.fullyQualifiedName) |
From: Vance K. <va...@us...> - 2006-01-20 17:10:23
|
User: vancek Date: 06/01/20 09:10:18 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: fixed embeddable superclass hierarchy implementation, fixed inheritance mapping hierarchy implementation Revision Changes Path 1.4 +20 -14 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.3 retrieving revision 1.4 diff -u -w -r1.3 -r1.4 --- EntityEmbeddable.vsl 19 Jan 2006 06:48:40 -0000 1.3 +++ EntityEmbeddable.vsl 20 Jan 2006 17:10:17 -0000 1.4 @@ -11,7 +11,7 @@ ## 2. an abstract class ## ## -#if (!$entity.requiresGeneralizationMapping) +#if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass) #**##set ($generatedFile = "${stringUtils.replace($entity.fullyQualifiedEntityEmbeddableName,'.','/')}.java") #else #**##set ($generatedFile = "${stringUtils.replace($entity.fullyQualifiedEntityName,'.','/')}.java") @@ -19,10 +19,10 @@ #set ($identifier = $entity.identifiers.iterator().next()) /** - * Autogenerated POJO EJB #if (!$entity.requiresGeneralizationMapping) super#end class for ${entity.entityName} containing the + * Autogenerated POJO EJB#if (!$entity.requiresGeneralizationMapping || $entity.embeddableSuperclass) embeddable super#end class for ${entity.entityName} containing the * bulk of the entity implementation. * - * This is#if (!$entity.requiresGeneralizationMapping) an embeddable super class and#end autogenerated by AndroMDA using the EJB3 + * This is#if (!$entity.requiresGeneralizationMapping || $entity.embeddableSuperclass) an embeddable super class and#end autogenerated by AndroMDA using the EJB3 * cartridge. * * DO NOT MODIFY this class. @@ -30,7 +30,7 @@ $entity.getDocumentation(" * ") * */ -#if (!$entity.requiresGeneralizationMapping) +#if (!$entity.requiresGeneralizationMapping || $entity.embeddableSuperclass) @javax.persistence.EmbeddableSuperclass#if ($entity.accessType)(access = javax.persistence.AccessType.${entity.accessType})#end #else @@ -39,20 +39,26 @@ #end @javax.persistence.EntityListener(${entity.fullyQualifiedEntityListenerName}.class) ## Include the Table annotation for a base class in inheritence hierarchy -## if but not the inheriting classes. -#if (!$entity.requiresGeneralizationMapping) +## but not in the subclasses. +## If a class is manually specified as an embeddable superclass, add +## the Table annotation to the subclass. +#if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass) @javax.persistence.Table(name = "${entity.tableName}") #end -#if ($entity.requiresSpecializationMapping) +## Only include the inheritance related annotations for inheritance mapping +## that doesn't involve embeddable superclass hierarchy. +#if ($entity.requiresSpecializationMapping && !$entity.embeddableSuperclass) @javax.persistence.Inheritance(strategy = javax.persistence.InheritanceType.${entity.inheritanceStrategy}, discriminatorType = javax.persistence.DiscriminatorType.${entity.discriminatorType}#if ($entity.discriminatorValue), discriminatorValue = "${entity.discriminatorValue}"#end) #**##if ($entity.inheritanceSingleTable || $entity.inheritanceJoined) @javax.persistence.DiscriminatorColumn(name = "${entity.discriminatorColumn}"#if ($entity.discriminatorColumnDefinition), columnDefinition = "${entity.discriminatorColumnDefinition}"#end#if ($entity.discriminatorLength > 0), length = ${entity.discriminatorLength}#end) #**##end -#elseif ($entity.requiresGeneralizationMapping) +#elseif ($entity.requiresGeneralizationMapping && !$entity.embeddableSuperclassGeneralizationExists) +## Only include the inheritance annotation for subclasses if the super class +## is NOT an embeddable superclass. @javax.persistence.Inheritance#if ($entity.discriminatorValue)(discriminatorValue = "${entity.discriminatorValue}")#end #end -public#if (!$entity.requiresGeneralizationMapping) abstract class ${entity.entityEmbeddableName}#else class ${entity.entityName}#end +public#if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass) abstract class ${entity.entityEmbeddableName}#else class ${entity.entityName}#end #if($entity.generalization) extends ${entity.generalization.fullyQualifiedName} @@ -110,7 +116,7 @@ /** * Default empty constructor */ - public #if (!$entity.requiresGeneralizationMapping)${entity.entityEmbeddableName}#else${entity.entityName}#end() + public #if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass)${entity.entityEmbeddableName}#else${entity.entityName}#end() { // default null constructor } @@ -128,7 +134,7 @@ * @param $attribute.name Value for the ${attribute.name} property #end */ - public #if (!$entity.requiresGeneralizationMapping)${entity.entityEmbeddableName}#else${entity.entityName}#end($entity.getAttributesAsList($allAttributes, true, true, false)) + public #if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass)${entity.entityEmbeddableName}#else${entity.entityName}#end($entity.getAttributesAsList($allAttributes, true, true, false)) { #if(!$inheritedAttributes.empty) super($entity.getAttributesAsList($inheritedAttributes, false, true, false)); @@ -150,7 +156,7 @@ * @param $relation.otherEnd.name Value for the ${relation.otherEnd.name} relation role #* *##end */ - public #if (!$entity.requiresGeneralizationMapping)${entity.entityEmbeddableName}#else${entity.entityName}#end($entity.getAttributesAsList($allAttributes, true, true, false)#if(!$allAttributes.empty), #end#foreach ($relation in $relations)#if ($relation.one2Many || $relation.many2Many)${relation.relationType}<${relation.otherEnd.type.name}> $relation.otherEnd.name#else${relation.relationType} $relation.otherEnd.name#end#if($velocityCount != $relations.size()), #end#end) + public #if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass)${entity.entityEmbeddableName}#else${entity.entityName}#end($entity.getAttributesAsList($allAttributes, true, true, false)#if(!$allAttributes.empty), #end#foreach ($relation in $relations)#if ($relation.one2Many || $relation.many2Many)${relation.relationType}<${relation.otherEnd.type.name}> $relation.otherEnd.name#else${relation.relationType} $relation.otherEnd.name#end#if($velocityCount != $relations.size()), #end#end) { // Call suitable class constructor this($entity.getAttributesAsList($allAttributes, false, true, false)); @@ -172,7 +178,7 @@ * @param $attribute Value for the $attribute property #**##end */ - public #if (!$entity.requiresGeneralizationMapping)${entity.entityEmbeddableName}#else${entity.entityName}#end(${operation.typedArgumentList}) + public #if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass)${entity.entityEmbeddableName}#else${entity.entityName}#end(${operation.typedArgumentList}) { #**##foreach($attribute in $opArguments) this.${attribute} = $attribute; @@ -186,7 +192,7 @@ * * @param pk Composite primary key */ - public #if (!$entity.requiresGeneralizationMapping)${entity.entityEmbeddableName}#else${entity.entityName}#end(${entity.fullyQualifiedEntityCompositePrimaryKeyName} pk) + public #if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass)${entity.entityEmbeddableName}#else${entity.entityName}#end(${entity.fullyQualifiedEntityCompositePrimaryKeyName} pk) { this.pk = pk; } |
From: Vance K. <va...@us...> - 2006-01-23 05:45:42
|
User: vancek Date: 06/01/22 21:45:31 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: check for syntheticCreateMethodAllowed for auto generated constructors and fixed composite PK column mapping by introducing AttributeOverrides annotation Revision Changes Path 1.5 +24 -10 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.4 retrieving revision 1.5 diff -u -w -r1.4 -r1.5 --- EntityEmbeddable.vsl 20 Jan 2006 17:10:17 -0000 1.4 +++ EntityEmbeddable.vsl 23 Jan 2006 05:45:31 -0000 1.5 @@ -125,32 +125,35 @@ #set ($allAttributes = $transform.filterByVisibility($entity.allInstanceAttributes, "public")) #set ($inheritedAttributes = $transform.filterByVisibility($entity.inheritedInstanceAttributes, "public")) #set ($instanceAttributes = $transform.filterByVisibility($entity.instanceAttributes, "public")) +#if ($entity.syntheticCreateMethodAllowed) /** * Implementation for the main constructor with all POJO attributes. * This method sets all POJO fields defined in this class to the * values provided by the parameters. * -#foreach($attribute in $transform.filterUpdatableAttributes($allAttributes, $entity.compositePrimaryKeyPresent)) +#**##foreach($attribute in $transform.filterUpdatableAttributes($allAttributes, $entity.compositePrimaryKeyPresent)) * @param $attribute.name Value for the ${attribute.name} property -#end +#**##end */ public #if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass)${entity.entityEmbeddableName}#else${entity.entityName}#end($entity.getAttributesAsList($allAttributes, true, true, false)) { -#if(!$inheritedAttributes.empty) +#**##if(!$inheritedAttributes.empty) super($entity.getAttributesAsList($inheritedAttributes, false, true, false)); -#end -#foreach ($attribute in $transform.filterUpdatableAttributes($instanceAttributes, $entity.compositePrimaryKeyPresent)) +#**##end +#**##foreach ($attribute in $transform.filterUpdatableAttributes($instanceAttributes, $entity.compositePrimaryKeyPresent)) ${attribute.setterName}(${attribute.name}); -#end +#**##end } +#end #set ($relations = $entity.allEntityRelations) #if (!$relations.empty) #**##if ($entity.syntheticCreateMethodAllowed) /** * Constructor with all POJO attribute values and CMR relations. -#* *##foreach($attribute in $allAttributes) - * @param $attribute.name Value for the $attribute.name property + * +#* *##foreach($attribute in $transform.filterUpdatableAttributes($allAttributes, $entity.compositePrimaryKeyPresent)) + * @param $attribute.name Value for the ${attribute.name} property #* *##end #* *##foreach ($relation in $relations) * @param $relation.otherEnd.name Value for the ${relation.otherEnd.name} relation role @@ -158,8 +161,9 @@ */ public #if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass)${entity.entityEmbeddableName}#else${entity.entityName}#end($entity.getAttributesAsList($allAttributes, true, true, false)#if(!$allAttributes.empty), #end#foreach ($relation in $relations)#if ($relation.one2Many || $relation.many2Many)${relation.relationType}<${relation.otherEnd.type.name}> $relation.otherEnd.name#else${relation.relationType} $relation.otherEnd.name#end#if($velocityCount != $relations.size()), #end#end) { - // Call suitable class constructor - this($entity.getAttributesAsList($allAttributes, false, true, false)); +#* *##foreach ($attribute in $transform.filterUpdatableAttributes($instanceAttributes, $entity.compositePrimaryKeyPresent)) + ${attribute.setterName}(${attribute.name}); +#* *##end // Set the CMR relations #* *##foreach ($relation in $relations) @@ -224,6 +228,16 @@ * @return The composite primary key */ @javax.persistence.EmbeddedId +#**##set ($identifiers = $entity.getIdentifiers()) +#**##if (!$identifiers.empty) + @javax.persistence.AttributeOverrides + ({ +#* *##foreach ($attribute in $identifiers) + @javax.persistence.AttributeOverride(name = "${attribute.name}", column = @javax.persistence.Column(name = "${attribute.columnName}"#if ($attribute.unique), unique = ${attribute.unique}#end#if (!$attribute.columnNullable), nullable = ${attribute.columnNullable}#end#if ($attribute.columnLength), length = ${attribute.columnLength}#end#if ($attribute.columnDefinition), columnDefinition = "${attribute.columnDefinition}"#end#if ($attribute.columnPrecision), precision = ${attribute.columnPrecision}#end#if ($attribute.columnScale), scale = ${attribute.columnScale}#end))#if($velocityCount != $identifiers.size()),#end + +#* *##end + }) +#**##end public ${entity.fullyQualifiedEntityCompositePrimaryKeyName} getPk() { return this.pk; |
From: Vance K. <va...@us...> - 2006-01-25 02:50:53
|
User: vancek Date: 06/01/24 18:50:48 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: added enumeration type to attribute, finder method's setParameter adds ordinal() or name() if parameter is an enumeration type with the corresponding base. fixed comments. Revision Changes Path 1.6 +20 -11 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.5 retrieving revision 1.6 diff -u -w -r1.5 -r1.6 --- EntityEmbeddable.vsl 23 Jan 2006 05:45:31 -0000 1.5 +++ EntityEmbeddable.vsl 25 Jan 2006 02:50:46 -0000 1.6 @@ -93,7 +93,7 @@ #* *##set ($doAttribute = true) #* *##end #* *##if ($doAttribute) - private $attribute.type.fullyQualifiedName $attribute.name; + private ${attribute.type.fullyQualifiedName} $attribute.name; #* *##end #**##end #end @@ -127,7 +127,7 @@ #set ($instanceAttributes = $transform.filterByVisibility($entity.instanceAttributes, "public")) #if ($entity.syntheticCreateMethodAllowed) /** - * Implementation for the main constructor with all POJO attributes. + * Implementation for the constructor with all POJO attributes. * This method sets all POJO fields defined in this class to the * values provided by the parameters. * @@ -293,17 +293,20 @@ #* *##if ($attribute.lazy) @javax.persistence.Basic(fetch = javax.persistence.FetchType.LAZY) #* *##end - public $attribute.type.fullyQualifiedName ${attribute.getterName}() + public ${attribute.type.fullyQualifiedName} ${attribute.getterName}() { return $attribute.name; } -## Allow only if not a version attribute since they are set by the container - No setter method is made available +## +## Allow only if attribute is not a version attribute since they are +## set by the container - No setter method is made available. +## /** * 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}(${attribute.type.fullyQualifiedName} value) { this.${attribute.name} = value; } @@ -467,6 +470,7 @@ { return em.createQuery("FROM ${entity.tableName} AS $stringUtils.uncapitalize(${entity.name})").getResultList(); } + #**##end ## Only include the findByPrimaryKey method if not an inheriting class. ## Classes that inherit from a base class use the primary key identifier @@ -511,9 +515,9 @@ #* *##set ($parameters = "javax.persistence.EntityManager em, ${parameterList}") #* *##end /** + * Finder method for ${entity.name} entity using a query. $finder.getDocumentation(" * ") * - * Finder method for ${entity.name} entity using a query. * @param em javax.persistence.EntityManager #* *##foreach ($parameter in $finder.arguments) * @param $parameter.type.fullyQualifiedName ${parameter.name} @@ -530,10 +534,15 @@ #* *##elseif ($parameter.maxResults) query.setMaxResults(${parameter.name}); #* *##else +## +## Find the attribute matching the parameter name +## If the parameter type is an enum: +## If +## #* *##if ($finder.useNamedParameters) - query.setParameter("${parameter.name}",#if ($parameter.type.primitive) new ${parameter.type.wrapperName}(${parameter.name})#else ${parameter.name}#end#if ($parameter.temporalType), javax.persistence.TemporalType.${parameter.temporalType}#end); + query.setParameter("${parameter.name}",#if ($parameter.type.primitive) new ${parameter.type.wrapperName}(${parameter.name})#else ${parameter.name}#if ($parameter.enumerationTypeOrdinal).ordinal()#elseif ($parameter.enumerationTypeString).name()#end#end#if ($parameter.temporalType), javax.persistence.TemporalType.${parameter.temporalType}#end); #* *##else - query.setParameter(${index},#if ($parameter.type.primitive) new ${parameter.type.wrapperName}(${parameter.name})#else ${parameter.name}#end#if ($parameter.temporalType), javax.persistence.TemporalType.${parameter.temporalType}#end); + query.setParameter(${index},#if ($parameter.type.primitive) new ${parameter.type.wrapperName}(${parameter.name})#else ${parameter.name}#if ($parameter.enumerationTypeOrdinal).ordinal()#elseif ($parameter.enumerationTypeString).name()#end#end#if ($parameter.temporalType), javax.persistence.TemporalType.${parameter.temporalType}#end); #* *##end #* *##end #* *##end |
From: Vance K. <va...@us...> - 2006-01-26 04:35:49
|
User: vancek Date: 06/01/25 20:35:42 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: fixed finder sql to use entity name rather than table name, moved Table and EntityListener annotations from embeddable superclass to inheriting entity class template, except for cases where this template generates the inheriting entity subclass Revision Changes Path 1.7 +11 -6 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.6 retrieving revision 1.7 diff -u -w -r1.6 -r1.7 --- EntityEmbeddable.vsl 25 Jan 2006 02:50:46 -0000 1.6 +++ EntityEmbeddable.vsl 26 Jan 2006 04:35:41 -0000 1.7 @@ -37,14 +37,19 @@ @javax.persistence.Entity#if ($entity.accessType)(access = javax.persistence.AccessType.${entity.accessType})#end #end -...@ja...rsistence.EntityListener(${entity.fullyQualifiedEntityListenerName}.class) -## Include the Table annotation for a base class in inheritence hierarchy -## but not in the subclasses. +## +## Include the Table annotation for a base class in single table inheritence hierarchy +## but not in the subclasses. Include in all classes for joined and table per class +## inheritance hierarchies. ## If a class is manually specified as an embeddable superclass, add -## the Table annotation to the subclass. -#if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass) +## the Table annotation to the subclass, not to the base superclass. +## +#if ($entity.requiresGeneralizationMapping && ($entity.embeddableSuperclassGeneralizationExists || $entity.inheritanceTablePerClass || $entity.inheritanceJoined)) @javax.persistence.Table(name = "${entity.tableName}") #end +#if ($entity.requiresGeneralizationMapping) +...@ja...rsistence.EntityListener(${entity.fullyQualifiedEntityListenerName}.class) +#end ## Only include the inheritance related annotations for inheritance mapping ## that doesn't involve embeddable superclass hierarchy. #if ($entity.requiresSpecializationMapping && !$entity.embeddableSuperclass) @@ -468,7 +473,7 @@ ## For inheriting classes, replace findAll with findAll${entity.name}s public static java.util.Collection<${entity.name}> findAll#if ($entity.requiresGeneralizationMapping)$stringUtils.capitalize(${entity.name})s#end(javax.persistence.EntityManager em) { - return em.createQuery("FROM ${entity.tableName} AS $stringUtils.uncapitalize(${entity.name})").getResultList(); + return em.createQuery("FROM ${entity.name} AS $stringUtils.uncapitalize(${entity.name})").getResultList(); } #**##end |
From: Vance K. <va...@us...> - 2006-01-26 06:58:49
|
User: vancek Date: 06/01/25 22:58:43 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: refactored to use EJB3AssociationEndFacade.getterSetterTypeName rather than relationType - depending on the enableTemplating variable, it will render mutator and accessors with generics Revision Changes Path 1.8 +29 -18 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.7 retrieving revision 1.8 diff -u -w -r1.7 -r1.8 --- EntityEmbeddable.vsl 26 Jan 2006 04:35:41 -0000 1.7 +++ EntityEmbeddable.vsl 26 Jan 2006 06:58:43 -0000 1.8 @@ -108,11 +108,10 @@ // --------- Relationship Definitions ----------- #**##foreach ($associationEnd in $entityRelations) -#**##**##if ($associationEnd.one2Many || $associationEnd.many2Many) - private $associationEnd.relationType<${associationEnd.otherEnd.type.name}> ${associationEnd.otherEnd.name}; -#**##**##else - private $associationEnd.relationType ${associationEnd.otherEnd.name}; -#**##**##end +#* *##set ($target = $associationEnd.otherEnd) +#* *##if ($target.navigable) + private $target.getterSetterTypeName ${target.name}; +#* *##end #**##end #end @@ -164,7 +163,7 @@ * @param $relation.otherEnd.name Value for the ${relation.otherEnd.name} relation role #* *##end */ - public #if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass)${entity.entityEmbeddableName}#else${entity.entityName}#end($entity.getAttributesAsList($allAttributes, true, true, false)#if(!$allAttributes.empty), #end#foreach ($relation in $relations)#if ($relation.one2Many || $relation.many2Many)${relation.relationType}<${relation.otherEnd.type.name}> $relation.otherEnd.name#else${relation.relationType} $relation.otherEnd.name#end#if($velocityCount != $relations.size()), #end#end) + public #if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass)${entity.entityEmbeddableName}#else${entity.entityName}#end($entity.getAttributesAsList($allAttributes, true, true, false)#if(!$allAttributes.empty), #end#foreach ($relation in $relations)${relation.otherEnd.getterSetterTypeName} $relation.otherEnd.name#if($velocityCount != $relations.size()), #end#end) { #* *##foreach ($attribute in $transform.filterUpdatableAttributes($instanceAttributes, $entity.compositePrimaryKeyPresent)) ${attribute.setterName}(${attribute.name}); @@ -333,12 +332,13 @@ ## /** * Get the ${target.name} - * @return $associationEnd.relationType + * + * @return $target.getterSetterTypeName */ #* *##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) @javax.persistence.JoinColumn(name = "$stringUtils.upperCase(${target.name})"#if ($associationEnd.columnDefinition), columnDefinition = "${associationEnd.columnDefinition}"#end) - public $associationEnd.relationType ${target.getterName}() + public $target.getterSetterTypeName ${target.getterName}() { return this.${target.name}; } @@ -346,12 +346,14 @@ #* *##if(!$target.readOnly) /** * Set the ${target.name} + * * @param ${target.name} */ - public void ${target.setterName}($associationEnd.relationType ${target.name}) + public void ${target.setterName}($target.getterSetterTypeName ${target.name}) { this.${target.name} = ${target.name}; } + #* *##end #* *##elseif ($associationEnd.one2Many) ## @@ -363,7 +365,8 @@ ## /** * Get the ${target.name} Collection - * @return $associationEnd.relationType + * + * @return $target.getterSetterTypeName */ #* *##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) @@ -374,19 +377,21 @@ @javax.persistence.OrderBy #* *##end #* *##end - public $associationEnd.relationType<${target.type.name}> ${target.getterName}() + public $target.getterSetterTypeName ${target.getterName}() { return this.${target.name}; } /** * Set the ${target.name} + * * @param ${target.name} */ - public void ${target.setterName} (${associationEnd.relationType}<${target.type.name}> ${target.name}) + public void ${target.setterName} (${target.getterSetterTypeName} ${target.name}) { this.${target.name} = ${target.name}; } + #* *##elseif ($associationEnd.one2One) ## ## ONE TO ONE RELATIONSHIP @@ -395,14 +400,15 @@ ## /** * Get the ${target.name} - * @return $associationEnd.relationType + * + * @return $target.getterSetterTypeName */ #* *##set ($argExists = false) @javax.persistence.OneToOne(#if (!$target.optional)optional = false#set ($argExists = true)#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) @javax.persistence.JoinColumn(name = "$stringUtils.upperCase(${target.name})"#if ($associationEnd.columnDefinition), columnDefinition = "${associationEnd.columnDefinition}"#end) #* *##end - public $associationEnd.relationType ${target.getterName}() + public $target.getterSetterTypeName ${target.getterName}() { return this.${target.name}; } @@ -410,12 +416,14 @@ #* *##if(!$target.readOnly) /** * Set the ${target.name} + * * @param ${target.name} */ - public void ${target.setterName}($associationEnd.relationType ${target.name}) + public void ${target.setterName}($target.getterSetterTypeName ${target.name}) { this.${target.name} = ${target.name}; } + #* *##end #* *##elseif ($associationEnd.many2Many) ## @@ -425,7 +433,8 @@ ## /** * Get the ${target.name} Collection - * @return $associationEnd.relationType + * + * @return $target.getterSetterTypeName */ #* *##set ($argExists = false) @javax.persistence.ManyToMany(#if ($target.cascadeType)cascade = {${target.cascadeType}}#set ($argExists = true)#end#if ($target.eager)#if ($argExists), #end#**#fetch = javax.persistence.FetchType.EAGER#end) @@ -440,19 +449,21 @@ @javax.persistence.OrderBy #* *##end #* *##end - public $associationEnd.relationType<${target.type.name}> ${target.getterName}() + public $target.getterSetterTypeName ${target.getterName}() { return this.${target.name}; } /** * Set the ${target.name} + * * @param ${target.name} */ - public void ${target.setterName} (${associationEnd.relationType}<${target.type.name}> ${target.name}) + public void ${target.setterName} (${target.getterSetterTypeName} ${target.name}) { this.${target.name} = ${target.name}; } + #* *##end #**##end #end |
From: Vance K. <va...@us...> - 2006-01-28 02:44:06
|
User: vancek Date: 06/01/27 18:43:59 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: only add optional element of OneToOne annotation on the owning side of the association Revision Changes Path 1.9 +3 -1 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.8 retrieving revision 1.9 diff -u -w -r1.8 -r1.9 --- EntityEmbeddable.vsl 26 Jan 2006 06:58:43 -0000 1.8 +++ EntityEmbeddable.vsl 28 Jan 2006 02:43:59 -0000 1.9 @@ -329,6 +329,7 @@ ## MANY TO ONE RELATIONSHIP ## ## Default fetch type: EAGER +## Has optional feature ## /** * Get the ${target.name} @@ -397,6 +398,7 @@ ## ONE TO ONE RELATIONSHIP ## ## Default fetch type: EAGER +## Add the optional feature on the owning side of a One-to-One relationship ## /** * Get the ${target.name} @@ -404,7 +406,7 @@ * @return $target.getterSetterTypeName */ #* *##set ($argExists = false) - @javax.persistence.OneToOne(#if (!$target.optional)optional = false#set ($argExists = true)#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) + @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) @javax.persistence.JoinColumn(name = "$stringUtils.upperCase(${target.name})"#if ($associationEnd.columnDefinition), columnDefinition = "${associationEnd.columnDefinition}"#end) #* *##end |
From: Vance K. <va...@us...> - 2006-01-31 15:18:04
|
User: vancek Date: 06/01/31 07:17:57 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: static constants are defined as public (not private), check to see if generic finders are modelled, Revision Changes Path 1.12 +7 -6 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.11 retrieving revision 1.12 diff -u -w -r1.11 -r1.12 --- EntityEmbeddable.vsl 29 Jan 2006 03:19:56 -0000 1.11 +++ EntityEmbeddable.vsl 31 Jan 2006 15:17:57 -0000 1.12 @@ -79,7 +79,7 @@ #**##foreach ($constant in $constants) @javax.persistence.Transient - private static final $constant.type.fullyQualifiedName $constant.name = $constant.defaultValue; + public static final $constant.type.fullyQualifiedName $constant.name = $constant.defaultValue; #**##end #end #set ($attributes = $entity.attributes) @@ -475,8 +475,8 @@ ## Do not include the findAll finder for inheriting classes when the ## inheritance strategy is single table. This is defined in the base -## class. -#**##if (($entity.inheritanceSingleTable && !$entity.requiresGeneralizationMapping) || !$entity.inheritanceSingleTable) +## class. Only render if the findAll finder hasn't been modelled. +#**##if ((($entity.inheritanceSingleTable && !$entity.requiresGeneralizationMapping) || !$entity.inheritanceSingleTable) && !$entity.finderFindAllExists) /** * Returns the collection of all ${entity.name}s. * @@ -496,7 +496,8 @@ ## queries, so queries based on the base/root class are polymorphic. ## Do not include the findByPrimaryKey if this bean has a composite ## primary key class. -#**##if (!$entity.compositePrimaryKeyPresent && !$entity.requiresGeneralizationMapping) +## Only render if the findAll finder hasn't been modelled. +#**##if (!$entity.compositePrimaryKeyPresent && !$entity.requiresGeneralizationMapping && !$entity.finderFindByPrimaryKeyExists) #* *##foreach ($attribute in $entity.getIdentifiers(false)) #* *##set ($identifierName = $attribute.name) #* *##set ($identifierType = $attribute.type.fullyQualifiedName) @@ -580,13 +581,13 @@ // --------------- Business Methods ----------------- -#**##foreach ($operation in ) +#**##foreach ($operation in $businessOperations) #* *##set ($signature = $operation.signature) #* *##set ($visibility = $operation.visibility.toString()) +#* *##set ($returnType = $operation.returnType.fullyQualifiedName) /** $operation.getDocumentation(" * ") */ -#* *##set ($returnType = $operation.returnType.fullyQualifiedName) #* *##if ($operation.exceptionsPresent) $visibility abstract $returnType $signature throws $operation.exceptionList; |
From: Vance K. <va...@us...> - 2006-02-01 08:38:52
|
User: vancek Date: 06/02/01 00:38:44 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: when defining attributes use allInstanceAttributes, fixed comments for constants, added mappedBy property for ManyToMany annotation, if method is modelled as classifier(static) do not declare it here. Revision Changes Path 1.13 +17 -11 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.12 retrieving revision 1.13 diff -u -w -r1.12 -r1.13 --- EntityEmbeddable.vsl 31 Jan 2006 15:17:57 -0000 1.12 +++ EntityEmbeddable.vsl 1 Feb 2006 08:38:44 -0000 1.13 @@ -82,7 +82,7 @@ public static final $constant.type.fullyQualifiedName $constant.name = $constant.defaultValue; #**##end #end -#set ($attributes = $entity.attributes) +#set ($attributes = $entity.allInstanceAttributes) #if (!$attributes.empty) // ----------- Attribute Definitions ------------ @@ -214,7 +214,7 @@ /** * Get the <code>$constant.name</code> constant $constant.getDocumentation(" * ") - * + */ $constant.visibility $constant.type.fullyQualifiedName ${constant.getterName}() { return $constant.name; @@ -262,7 +262,7 @@ // -------- Attribute Accessors ---------- -#**##foreach ($attribute in $entity.attributes) +#**##foreach ($attribute in $attributes) ## Only include accessors for identifier attributes if entity does not have a composite primary key #* *##if ($entity.compositePrimaryKeyPresent && $attribute.identifier) #* *##set ($doAttributeAccessors = false) @@ -439,7 +439,7 @@ * @return $target.getterSetterTypeName */ #* *##set ($argExists = false) - @javax.persistence.ManyToMany(#if ($target.cascadeType)cascade = {${target.cascadeType}}#set ($argExists = true)#end#if ($target.eager)#if ($argExists), #end#**#fetch = javax.persistence.FetchType.EAGER#end) + @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 #* *##if(($associationEnd.owning) && ${associationEnd.association.tableName}) @javax.persistence.JoinTable(table = @javax.persistence.Table(name = "${associationEnd.association.tableName}")) @@ -579,9 +579,13 @@ #set ($businessOperations = $entity.businessOperations) #if (!$businessOperations.empty) - // --------------- Business Methods ----------------- + // --------------- Entity Methods ----------------- +## +## Method with a static modifier will be defined in the inheriting subclass +## #**##foreach ($operation in $businessOperations) +#* *##if (!$operation.static) #* *##set ($signature = $operation.signature) #* *##set ($visibility = $operation.visibility.toString()) #* *##set ($returnType = $operation.returnType.fullyQualifiedName) @@ -594,6 +598,8 @@ #* *##else $visibility abstract $returnType $signature; #* *##end + +#* *##end #**##end #end } \ No newline at end of file |
From: Vance K. <va...@us...> - 2006-02-06 03:04:14
|
User: vancek Date: 06/02/05 19:04:06 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: renamed @EmbeddableSuperclass to @MappedSuperclass removed access type for @MappedSuperclass and @Entity - figured out automatically moved generator properties from @Id to @GeneratedValue added @SequenceGenerator and fixed @TableGenerator properties removed type property from @Lob - determined from attribute type moved fetch property from @Lob to @Basic added @Temporal annotation to entity attribute getter added @Enumerated annotation to entity attribute getter fixed inheritance discriminator annotations, @Inheritance, @DiscriminatorColumn and @DiscriminatorValue (new) renamed @EntityListener to @EntityListeners when defining attributes, use instanceAttributes only, not allInstanceAttributes (excludes inherited isntance atts) added @JoinColumns if composite PK present on Many-To-One and One-To-One relationships added @JoinTable on owning side of Many-To-Many relationship removed entity business operations - only exist in impl class Revision Changes Path 1.14 +88 -48 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.13 retrieving revision 1.14 diff -u -w -r1.13 -r1.14 --- EntityEmbeddable.vsl 1 Feb 2006 08:38:44 -0000 1.13 +++ EntityEmbeddable.vsl 6 Feb 2006 03:04:06 -0000 1.14 @@ -19,10 +19,10 @@ #set ($identifier = $entity.identifiers.iterator().next()) /** - * Autogenerated POJO EJB#if (!$entity.requiresGeneralizationMapping || $entity.embeddableSuperclass) embeddable super#end class for ${entity.entityName} containing the + * Autogenerated POJO EJB#if (!$entity.requiresGeneralizationMapping || $entity.embeddableSuperclass) embeddable/mapped super#end class for ${entity.entityName} containing the * bulk of the entity implementation. * - * This is#if (!$entity.requiresGeneralizationMapping || $entity.embeddableSuperclass) an embeddable super class and#end autogenerated by AndroMDA using the EJB3 + * This is#if (!$entity.requiresGeneralizationMapping || $entity.embeddableSuperclass) an embeddable/mapped super class and#end autogenerated by AndroMDA using the EJB3 * cartridge. * * DO NOT MODIFY this class. @@ -31,11 +31,9 @@ * */ #if (!$entity.requiresGeneralizationMapping || $entity.embeddableSuperclass) -...@ja...rsistence.EmbeddableSuperclass#if ($entity.accessType)(access = javax.persistence.AccessType.${entity.accessType})#end - +...@ja...ppedSuperclass #else -...@ja...rsistence.Entity#if ($entity.accessType)(access = javax.persistence.AccessType.${entity.accessType})#end - +...@ja...rsistence.Entity #end ## ## Include the Table annotation for a base class in single table inheritence hierarchy @@ -48,20 +46,25 @@ @javax.persistence.Table(name = "${entity.tableName}") #end #if ($entity.requiresGeneralizationMapping && $entity.listenerEnabled) -...@ja...rsistence.EntityListener(${entity.fullyQualifiedEntityListenerName}.class) +...@ja...rsistence.EntityListeners({${entity.fullyQualifiedEntityListenerName}.class}) #end +## ## Only include the inheritance related annotations for inheritance mapping ## that doesn't involve embeddable superclass hierarchy. +## #if ($entity.requiresSpecializationMapping && !$entity.embeddableSuperclass) -...@ja...heritance(strategy = javax.persistence.InheritanceType.${entity.inheritanceStrategy}, discriminatorType = javax.persistence.DiscriminatorType.${entity.discriminatorType}#if ($entity.discriminatorValue), discriminatorValue = "${entity.discriminatorValue}"#end) +...@ja...heritance(strategy = javax.persistence.InheritanceType.${entity.inheritanceStrategy}) #**##if ($entity.inheritanceSingleTable || $entity.inheritanceJoined) -...@ja...rsistence.DiscriminatorColumn(name = "${entity.discriminatorColumn}"#if ($entity.discriminatorColumnDefinition), columnDefinition = "${entity.discriminatorColumnDefinition}"#end#if ($entity.discriminatorLength > 0), length = ${entity.discriminatorLength}#end) +#* *##set ($argExists = false) +...@ja...rsistence.DiscriminatorColumn(#if ($entity.discriminatorColumn)name = "${entity.discriminatorColumn}"#set ($argExists = true)#end#if ($entity.discriminatorType)#if ($argExists), #end#**#discriminatorType = javax.persistence.DiscriminatorType.${entity.discriminatorType}#set ($argExists = true)#end#if ($entity.discriminatorColumnDefinition)#if ($argExists), #end#**#columnDefinition = "${entity.discriminatorColumnDefinition}"#set ($argExists = true)#end#if ($entity.discriminatorLength > 0)#if ($argExists), #end#**#length = ${entity.discriminatorLength}#end) +...@ja...rsistence.DiscriminatorValue("${entity.discriminatorValue}") #**##end #elseif ($entity.requiresGeneralizationMapping && !$entity.embeddableSuperclassGeneralizationExists) -## Only include the inheritance annotation for subclasses if the super class +## +## Only include the DiscriminatorValue annotation for subclasses if the super class ## is NOT an embeddable superclass. -...@ja...heritance#if ($entity.discriminatorValue)(discriminatorValue = "${entity.discriminatorValue}")#end - +## +...@ja...rsistence.DiscriminatorValue("${entity.discriminatorValue}") #end public#if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass) abstract class ${entity.entityEmbeddableName}#else class ${entity.entityName}#end @@ -82,7 +85,10 @@ public static final $constant.type.fullyQualifiedName $constant.name = $constant.defaultValue; #**##end #end -#set ($attributes = $entity.allInstanceAttributes) +## +## Only declase instance attributes that are NOT inherited +## +#set ($attributes = $entity.instanceAttributes) #if (!$attributes.empty) // ----------- Attribute Definitions ------------ @@ -277,10 +283,15 @@ * @return $attribute.type.fullyQualifiedName The value of ${attribute.name} */ #* *##if ($attribute.identifier) -#* *##if ($attribute.sequenceGeneratorType || $attribute.tableGeneratorType) - @javax.persistence.TableGenerator(name = "${attribute.generatorName}"#if ($attribute.sequenceGeneratorType), sequenceName = "${attribute.generatorSourceName}"#elseif ($attribute.tableGeneratorType), tableName = "${attribute.generatorSourceName}"#end,#if ($attribute.tableGeneratorType) pkColumnValue = "${attribute.generatorPkColumnValue}",#end#if ($attribute.sequenceGeneratorType) initialValue = ${attribute.generatorInitialValue},#end allocationSize = ${attribute.generatorAllocationSize}) + @javax.persistence.Id +#* *##if ($attribute.sequenceGeneratorType) + @javax.persistence.SequenceGenerator(name = "${attribute.generatorName}"#if ($attribute.sequenceGeneratorType), sequenceName = "${attribute.generatorSourceName}"#end#if ($attribute.sequenceGeneratorType), initialValue = ${attribute.generatorInitialValue}#end#if ($attribute.generatorAllocationSize), allocationSize = ${attribute.generatorAllocationSize}#end) +#* *##elseif ($attribute.tableGeneratorType) + @javax.persistence.TableGenerator(name = "${attribute.generatorName}"#if ($attribute.tableGeneratorType), table = "${attribute.generatorSourceName}"#end#if ($attribute.generatorPkColumnValue), pkColumnValue = "${attribute.generatorPkColumnValue}"#end#if ($attribute.generatorInitialValue), initialValue = ${attribute.generatorInitialValue}#end#if ($attribute.generatorAllocationSize), allocationSize = ${attribute.generatorAllocationSize}#end) +#* *##end +#* *##if (!$attribute.generatorTypeNone) + @javax.persistence.GeneratedValue(strategy = javax.persistence.GenerationType.${attribute.generatorType}#if ($attribute.sequenceGeneratorType || $attribute.tableGeneratorType), generator = "${attribute.generatorName}"#end) #* *##end - @javax.persistence.Id(generate = javax.persistence.GeneratorType.${attribute.generatorType}#if ($attribute.sequenceGeneratorType || $attribute.tableGeneratorType), generator = "${attribute.generatorName}"#end) #* *##end #* *##if ($attribute.version) @javax.persistence.Version @@ -288,15 +299,30 @@ #* *##if ($attribute.transient) @javax.persistence.Transient #* *##end -#* *##if ($attribute.lobType) -## LOB type is specified - also sepcify FetchType if set to EAGER since default fetch type for LOB annotation is LAZY - @javax.persistence.Lob(type = javax.persistence.LobType.${attribute.lobType}#if ($attribute.eager), fetch = javax.persistence.FetchType.EAGER#end) +#* *##if ($attribute.lob) +## +## Add if LOB type is specified - do not set LOB type as of PFD Spec - inferred from type. +## Also sepcify Fetch type in Basic annotation if set to EAGER since +## default fetch type for LOB annotation is LAZY. +## + @javax.persistence.Lob +#* *##if ($attribute.eager) + @javax.persistence.Basic(fetch = javax.persistence.FetchType.EAGER) +#* *##end #* *##end @javax.persistence.Column(name = "${attribute.columnName}"#if ($attribute.unique), unique = ${attribute.unique}#end#if (!$attribute.columnNullable), nullable = ${attribute.columnNullable}#end#if ($attribute.columnLength), length = ${attribute.columnLength}#end#if ($attribute.columnDefinition), columnDefinition = "${attribute.columnDefinition}"#end#if ($attribute.columnPrecision), precision = ${attribute.columnPrecision}#end#if ($attribute.columnScale), scale = ${attribute.columnScale}#end) +#* *##if (!$attribute.lob && $attribute.lazy) +## ## Only add the fetch type property for LAZY hints - default is EAGER -#* *##if ($attribute.lazy) +## @javax.persistence.Basic(fetch = javax.persistence.FetchType.LAZY) #* *##end +#* *##if ($stringUtils.isNotBlank($attribute.temporalType)) + @javax.persistence.Temporal(javax.persistence.TemporalType.${attribute.temporalType}) +#* *##end +#* *##if ($stringUtils.isNotBlank($attribute.enumerationType)) + @javax.persistence.Enumerated(${attribute.enumerationType}) +#* *##end public ${attribute.type.fullyQualifiedName} ${attribute.getterName}() { return $attribute.name; @@ -338,7 +364,22 @@ */ #* *##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) +## +## Add the JoinColumns annotation if the target entity has a composite primary key +## Otherwise add the JoinColumn annotation. +## +#* *##if (!$target.type.compositePrimaryKeyPresent) @javax.persistence.JoinColumn(name = "$stringUtils.upperCase(${target.name})"#if ($associationEnd.columnDefinition), columnDefinition = "${associationEnd.columnDefinition}"#end) +#* *##else +#* *##set ($identifiers = $target.type.getIdentifiers()) + @javax.persistence.JoinColumns + ({ +#* *##foreach ($attribute in $identifiers) + @javax.persistence.JoinColumn(name = "$stringUtils.upperCase(${target.name})_${attribute.columnName}", referencedColumnName = "${attribute.columnName}")#if($velocityCount != $identifiers.size()),#end + +#* *##end + }) +#* *##end public $target.getterSetterTypeName ${target.getterName}() { return this.${target.name}; @@ -408,7 +449,22 @@ #* *##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) +## +## Add the JoinColumns annotation if the target entity has a composite primary key +## Otherwise add the JoinColumn annotation. +## +#* *##if (!$target.type.compositePrimaryKeyPresent) @javax.persistence.JoinColumn(name = "$stringUtils.upperCase(${target.name})"#if ($associationEnd.columnDefinition), columnDefinition = "${associationEnd.columnDefinition}"#end) +#* *##else +#* *##set ($identifiers = $target.type.getIdentifiers()) + @javax.persistence.JoinColumns + ({ +#* *##foreach ($attribute in $identifiers) + @javax.persistence.JoinColumn(name = "$stringUtils.upperCase(${target.name})_${attribute.columnName}", referencedColumnName = "${attribute.columnName}")#if($velocityCount != $identifiers.size()),#end + +#* *##end + }) +#* *##end #* *##end public $target.getterSetterTypeName ${target.getterName}() { @@ -441,8 +497,18 @@ #* *##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 -#* *##if(($associationEnd.owning) && ${associationEnd.association.tableName}) - @javax.persistence.JoinTable(table = @javax.persistence.Table(name = "${associationEnd.association.tableName}")) +#* *##if (${associationEnd.association.tableName}) +#* *##if($associationEnd.owning) +## +## Add the JoinTable annotation on the owning side +## + @javax.persistence.JoinTable + ( + name = "${associationEnd.association.tableName}", + joinColumns = {#set ($identifiers = $entity.getIdentifiers())#foreach ($attribute in $identifiers)@javax.persistence.JoinColumn(name = "${attribute.columnName}")#if($velocityCount != $identifiers.size()), #end#end#**#}, + inverseJoinColumns = {#set ($identifiers = $target.type.getIdentifiers())#foreach ($attribute in $identifiers)@javax.persistence.JoinColumn(name = "${attribute.columnName}")#if($velocityCount != $identifiers.size()), #end#end#**#} + ) +#* *##end #* *##end #* *##if ($target.hasTaggedValue("@andromda.persistence.orderBy")) #* *##if ($stringUtils.isNotEmpty(${target.orderByClause})) @@ -576,30 +642,4 @@ #**##end #end -#set ($businessOperations = $entity.businessOperations) -#if (!$businessOperations.empty) - - // --------------- Entity Methods ----------------- - -## -## Method with a static modifier will be defined in the inheriting subclass -## -#**##foreach ($operation in $businessOperations) -#* *##if (!$operation.static) -#* *##set ($signature = $operation.signature) -#* *##set ($visibility = $operation.visibility.toString()) -#* *##set ($returnType = $operation.returnType.fullyQualifiedName) - /** -$operation.getDocumentation(" * ") - */ -#* *##if ($operation.exceptionsPresent) - $visibility abstract $returnType $signature - throws $operation.exceptionList; -#* *##else - $visibility abstract $returnType $signature; -#* *##end - -#* *##end -#**##end -#end } \ No newline at end of file |
From: Vance K. <va...@us...> - 2006-02-09 07:05:16
|
User: vancek Date: 06/02/08 23:05:10 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: added insertable and updatable properties to @Column for attributes fixed @Enumerated value to include fully qualified value - javax.persistence.EnumType Revision Changes Path 1.15 +2 -2 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.14 retrieving revision 1.15 diff -u -w -r1.14 -r1.15 --- EntityEmbeddable.vsl 6 Feb 2006 03:04:06 -0000 1.14 +++ EntityEmbeddable.vsl 9 Feb 2006 07:05:10 -0000 1.15 @@ -310,7 +310,7 @@ @javax.persistence.Basic(fetch = javax.persistence.FetchType.EAGER) #* *##end #* *##end - @javax.persistence.Column(name = "${attribute.columnName}"#if ($attribute.unique), unique = ${attribute.unique}#end#if (!$attribute.columnNullable), nullable = ${attribute.columnNullable}#end#if ($attribute.columnLength), length = ${attribute.columnLength}#end#if ($attribute.columnDefinition), columnDefinition = "${attribute.columnDefinition}"#end#if ($attribute.columnPrecision), precision = ${attribute.columnPrecision}#end#if ($attribute.columnScale), scale = ${attribute.columnScale}#end) + @javax.persistence.Column(name = "${attribute.columnName}"#if ($attribute.unique), unique = ${attribute.unique}#end#if (!$attribute.columnNullable), nullable = ${attribute.columnNullable}#end#**#, insertable = ${attribute.insertEnabled}, updatable = ${attribute.updateEnabled}#if ($attribute.columnLength), length = ${attribute.columnLength}#end#if ($attribute.columnDefinition), columnDefinition = "${attribute.columnDefinition}"#end#if ($attribute.columnPrecision), precision = ${attribute.columnPrecision}#end#if ($attribute.columnScale), scale = ${attribute.columnScale}#end) #* *##if (!$attribute.lob && $attribute.lazy) ## ## Only add the fetch type property for LAZY hints - default is EAGER @@ -321,7 +321,7 @@ @javax.persistence.Temporal(javax.persistence.TemporalType.${attribute.temporalType}) #* *##end #* *##if ($stringUtils.isNotBlank($attribute.enumerationType)) - @javax.persistence.Enumerated(${attribute.enumerationType}) + @javax.persistence.Enumerated(javax.persistence.EnumType.${attribute.enumerationType}) #* *##end public ${attribute.type.fullyQualifiedName} ${attribute.getterName}() { |
From: Vance K. <va...@us...> - 2006-02-20 05:12:18
|
User: vancek Date: 06/02/19 21:12:16 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: delcare manageable entity display attribute if specified also define the getter/setter methods on this attribute Revision Changes Path 1.16 +62 -0 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.15 retrieving revision 1.16 diff -u -w -r1.15 -r1.16 --- EntityEmbeddable.vsl 9 Feb 2006 07:05:10 -0000 1.15 +++ EntityEmbeddable.vsl 20 Feb 2006 05:12:16 -0000 1.16 @@ -120,7 +120,30 @@ #* *##end #**##end #end +#if (!$entityRelations.empty) + // ---- Manageable Display Attributes (Transient) ----- + +## +## For manageable entities where the display attribute differs from identifier +## we need to specify a labels attribute which is transient (specified by annotation) +## on getter. A display attribute differs from the identifier if modelled by +## the Unique stereotype. +## +#**##foreach ($associationEnd in $entityRelations) +#* *##set ($target = $associationEnd.otherEnd) +#* *##if ($target.navigable) +#* *##if ($target.type.manageable && $target.type.manageableDisplayAttribute.name != $target.type.identifer.name) +#* *##if ($target.many) + private java.util.Collection<${target.type.manageableDisplayAttribute.type.fullyQualifiedName}> ${target.labelName}; // Manageable display attribute +#* *##else + private $target.type.manageableDisplayAttribute.type.fullyQualifiedName ${target.labelName}; // Manageable display attribute +#* *##end +#* *##end +#* *##end +#**##end + +#end // --------------- Constructors ----------------- /** @@ -535,6 +558,45 @@ #* *##end #**##end #end +#foreach ($associationEnd in $entity.allEntityRelations) +#**##set ($target = $associationEnd.otherEnd) +#**##if($target.navigable) +## +## For manageable entities where the display attribute differs from identifier +## we need to specify a labels attribute which is transient (specified by annotation) +## on getter. A display attribute differs from the identifier if modelled by +## the Unique stereotype. +## +#* *##if ($target.type.manageable && $target.type.manageableDisplayAttribute.name != $target.type.identifer.name) +#* *##if ($velocityCount == 1) + // -------- Manageable Attribute Display ----------- + +#* *##end + /** + * Get the ${target.labelName} + * + * @return #if ($target.many)java.util.Collection<${target.type.manageableDisplayAttribute.type.fullyQualifiedName}>#else${target.type.manageableDisplayAttribute.type.fullyQualifiedName}#end + + */ + @javax.persistence.Transient + public #if ($target.many)java.util.Collection<${target.type.manageableDisplayAttribute.type.fullyQualifiedName}>#else${target.type.manageableDisplayAttribute.type.fullyQualifiedName}#end ${target.getterLabelName}() + { + return this.${target.labelName}; + } + + /** + * Set the ${target.labelName} + * + * @param ${target.labelName} + */ + public void ${target.setterLabelName} (#if ($target.many)java.util.Collection<${target.type.manageableDisplayAttribute.type.fullyQualifiedName}>#else${target.type.manageableDisplayAttribute.type.fullyQualifiedName}#end ${target.labelName}) + { + this.${target.labelName} = ${target.labelName}; + } + +#* *##end +#**##end +#end #if ($entity.genericFinders) // ----------- Generic Finder Methods -------------- |
From: Vance K. <va...@us...> - 2006-02-22 06:12:57
|
User: vancek Date: 06/02/21 22:12:56 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: render implements interfaces as comma separated list Revision Changes Path 1.17 +3 -0 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.16 retrieving revision 1.17 diff -u -w -r1.16 -r1.17 --- EntityEmbeddable.vsl 20 Feb 2006 05:12:16 -0000 1.16 +++ EntityEmbeddable.vsl 22 Feb 2006 06:12:55 -0000 1.17 @@ -72,6 +72,9 @@ extends ${entity.generalization.fullyQualifiedName} #end implements java.io.Serializable +#if (!$entity.interfaceAbstractions.empty) + , $entity.implementedInterfaceList +#end { private static final long serialVersionUID = ${entity.serialVersionUID}L; |
From: Vance K. <va...@us...> - 2006-02-25 14:43:12
|
User: vancek Date: 06/02/25 06:43:11 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: discriminator components are only generated for single table hierarchy Revision Changes Path 1.18 +15 -2 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.17 retrieving revision 1.18 diff -u -w -r1.17 -r1.18 --- EntityEmbeddable.vsl 22 Feb 2006 06:12:55 -0000 1.17 +++ EntityEmbeddable.vsl 25 Feb 2006 14:43:11 -0000 1.18 @@ -54,7 +54,10 @@ ## #if ($entity.requiresSpecializationMapping && !$entity.embeddableSuperclass) @javax.persistence.Inheritance(strategy = javax.persistence.InheritanceType.${entity.inheritanceStrategy}) -#**##if ($entity.inheritanceSingleTable || $entity.inheritanceJoined) +## +## Discriminator components only apply to single table mapping strategy +## +#**##if ($entity.inheritanceSingleTable) #* *##set ($argExists = false) @javax.persistence.DiscriminatorColumn(#if ($entity.discriminatorColumn)name = "${entity.discriminatorColumn}"#set ($argExists = true)#end#if ($entity.discriminatorType)#if ($argExists), #end#**#discriminatorType = javax.persistence.DiscriminatorType.${entity.discriminatorType}#set ($argExists = true)#end#if ($entity.discriminatorColumnDefinition)#if ($argExists), #end#**#columnDefinition = "${entity.discriminatorColumnDefinition}"#set ($argExists = true)#end#if ($entity.discriminatorLength > 0)#if ($argExists), #end#**#length = ${entity.discriminatorLength}#end) @javax.persistence.DiscriminatorValue("${entity.discriminatorValue}") @@ -604,9 +607,13 @@ // ----------- Generic Finder Methods -------------- +## ## Do not include the findAll finder for inheriting classes when the ## inheritance strategy is single table. This is defined in the base -## class. Only render if the findAll finder hasn't been modelled. +## class. +## +## Only render if the findAll finder hasn't been modelled. +## #**##if ((($entity.inheritanceSingleTable && !$entity.requiresGeneralizationMapping) || !$entity.inheritanceSingleTable) && !$entity.finderFindAllExists) /** * Returns the collection of all ${entity.name}s. @@ -614,20 +621,26 @@ * @param em javax.persistence.EntityManager * @return all available ${entity.name} objects */ +## ## For inheriting classes, replace findAll with findAll${entity.name}s +## public static java.util.Collection<${entity.name}> findAll#if ($entity.requiresGeneralizationMapping)$stringUtils.capitalize(${entity.name})s#end(javax.persistence.EntityManager em) { return em.createQuery("FROM ${entity.name} AS $stringUtils.uncapitalize(${entity.name})").getResultList(); } #**##end +## ## Only include the findByPrimaryKey method if not an inheriting class. ## Classes that inherit from a base class use the primary key identifier ## of the base class. The inheritence relationship is reflected in the ## queries, so queries based on the base/root class are polymorphic. +## ## Do not include the findByPrimaryKey if this bean has a composite ## primary key class. +## ## Only render if the findAll finder hasn't been modelled. +## #**##if (!$entity.compositePrimaryKeyPresent && !$entity.requiresGeneralizationMapping && !$entity.finderFindByPrimaryKeyExists) #* *##foreach ($attribute in $entity.getIdentifiers(false)) #* *##set ($identifierName = $attribute.name) |
From: Vance K. <va...@us...> - 2006-03-07 01:49:53
|
User: vancek Date: 06/03/06 17:49:53 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: if user defined finder methods have a return type void, then invoke executeUpdate rather than return result Revision Changes Path 1.19 +4 -2 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.18 retrieving revision 1.19 diff -u -w -r1.18 -r1.19 --- EntityEmbeddable.vsl 25 Feb 2006 14:43:11 -0000 1.18 +++ EntityEmbeddable.vsl 7 Mar 2006 01:49:53 -0000 1.19 @@ -687,7 +687,7 @@ #* *##end * @return $returnType */ - $finder.visibility static $returnType#if ($returnType == "java.util.Collection" || $returnType == "java.util.List")<${entity.name}>#end ${finder.name}($parameters) + $finder.visibility static $returnType#if ($finder.returnType.collectionType || $finder.returnType.listType || $finder.returnType.setType || $finder.returnType.mapType)<${entity.name}>#end ${finder.name}($parameters) { javax.persistence.Query query = em.createQuery("$finder.query"); #* *##foreach ($parameter in $finder.arguments) @@ -709,7 +709,9 @@ #* *##end #* *##end #* *##end -#* *##if ($finder.returnType.primitive) +#* *##if ($stringUtils.equalsIgnoreCase($returnType, "void")) + query.executeUpdate(); +#* *##elseif ($finder.returnType.primitive) return (($finder.returnType.wrapperName)query.getSingleResult()).${returnType}Value(); #* *##elseif (!$finder.returnType.collectionType) return ($returnType)query.getSingleResult(); |
From: Vance K. <va...@us...> - 2006-03-14 06:06:04
|
User: vancek Date: 06/03/13 22:05:03 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: added @org.hibernate.annotations.Cache annotation at class level if entity cache enabled. added @org.hibernate.annotations.Cache annotation on One-To-Many and Many-To-Many relationships if association cache enabled. set org.hibernate.cacheRegion hint for queries with query cache enabled. Revision Changes Path 1.20 +12 -0 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.19 retrieving revision 1.20 diff -u -w -r1.19 -r1.20 --- EntityEmbeddable.vsl 7 Mar 2006 01:49:53 -0000 1.19 +++ EntityEmbeddable.vsl 14 Mar 2006 06:05:02 -0000 1.20 @@ -69,6 +69,9 @@ ## @javax.persistence.DiscriminatorValue("${entity.discriminatorValue}") #end +#if ($entity.cacheEnabled) +...@or...che(usage = org.hibernate.annotations.CacheConcurrencyStrategy.${entity.cacheType}) +#end public#if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass) abstract class ${entity.entityEmbeddableName}#else class ${entity.entityName}#end #if($entity.generalization) @@ -448,6 +451,9 @@ @javax.persistence.OrderBy #* *##end #* *##end +#* *##if ($target.associationCacheEnabled) + @org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.${target.cacheType}) +#* *##end public $target.getterSetterTypeName ${target.getterName}() { return this.${target.name}; @@ -546,6 +552,9 @@ @javax.persistence.OrderBy #* *##end #* *##end +#* *##if ($target.associationCacheEnabled) + @org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.${target.cacheType}) +#* *##end public $target.getterSetterTypeName ${target.getterName}() { return this.${target.name}; @@ -709,6 +718,9 @@ #* *##end #* *##end #* *##end +#* *##if ($finder.useQueryCache) + query.setHint("org.hibernate.cacheRegion", "/${entity.fullyQualifiedNamePath}/${finder.name}"); +#* *##end #* *##if ($stringUtils.equalsIgnoreCase($returnType, "void")) query.executeUpdate(); #* *##elseif ($finder.returnType.primitive) |
From: Vance K. <va...@us...> - 2006-03-16 02:08:38
|
User: vancek Date: 06/03/15 18:08:36 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: added @Transient annotation to relationship getters Revision Changes Path 1.21 +12 -0 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.20 retrieving revision 1.21 diff -u -w -r1.20 -r1.21 --- EntityEmbeddable.vsl 14 Mar 2006 06:05:02 -0000 1.20 +++ EntityEmbeddable.vsl 16 Mar 2006 02:08:34 -0000 1.21 @@ -394,6 +394,9 @@ * * @return $target.getterSetterTypeName */ +#* *##if ($target.transient) + @javax.persistence.Transient +#* *##end #* *##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) ## @@ -442,6 +445,9 @@ * * @return $target.getterSetterTypeName */ +#* *##if ($target.transient) + @javax.persistence.Transient +#* *##end #* *##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")) @@ -481,6 +487,9 @@ * * @return $target.getterSetterTypeName */ +#* *##if ($target.transient) + @javax.persistence.Transient +#* *##end #* *##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) @@ -529,6 +538,9 @@ * * @return $target.getterSetterTypeName */ +#* *##if ($target.transient) + @javax.persistence.Transient +#* *##end #* *##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 |
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}; |
From: Vance K. <va...@us...> - 2006-03-20 08:16:22
|
User: vancek Date: 06/03/20 00:15:35 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: set the hint org.hibernate.cacheRegion on query if not using default cache region. Revision Changes Path 1.23 +2 -2 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.22 retrieving revision 1.23 diff -u -w -r1.22 -r1.23 --- EntityEmbeddable.vsl 16 Mar 2006 15:26:23 -0000 1.22 +++ EntityEmbeddable.vsl 20 Mar 2006 08:15:34 -0000 1.23 @@ -765,8 +765,8 @@ #* *##end #* *##end #* *##end -#* *##if ($finder.useQueryCache) - query.setHint("org.hibernate.cacheRegion", "/${entity.fullyQualifiedNamePath}/${finder.name}"); +#* *##if ($finder.useQueryCache && !$entity.useDefaultCacheRegion) + query.setHint("org.hibernate.cacheRegion", "/${entity.fullyQualifiedNamePath}_${finder.name}"); #* *##end #* *##if ($stringUtils.equalsIgnoreCase($returnType, "void")) query.executeUpdate(); |
From: Vance K. <va...@us...> - 2006-04-24 02:26:53
|
User: vancek Date: 06/04/23 19:26:51 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: added support for embedded value object as an attribute, setting the AttributeOverride annotation Revision Changes Path 1.24 +11 -0 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.23 retrieving revision 1.24 diff -u -w -r1.23 -r1.24 --- EntityEmbeddable.vsl 20 Mar 2006 08:15:34 -0000 1.23 +++ EntityEmbeddable.vsl 24 Apr 2006 02:26:51 -0000 1.24 @@ -357,7 +357,18 @@ @javax.persistence.Basic(fetch = javax.persistence.FetchType.EAGER) #* *##end #* *##end +#* *##if ($attribute.containsEmbeddedObject) + @javax.persistence.Embedded + @javax.persistence.AttributeOverrides + ({ +#* *##foreach ($embeddedAttribute in $attribute.type.attributes) + @javax.persistence.AttributeOverride(name = "${embeddedAttribute.name}", column = @javax.persistence.Column(name = "${embeddedAttribute.columnName}"#if ($embeddedAttribute.unique), unique = ${embeddedAttribute.unique}#end#if (!$embeddedAttribute.columnNullable), nullable = ${embeddedAttribute.columnNullable}#end#**#, insertable = ${embeddedAttribute.insertEnabled}, updatable = ${embeddedAttribute.updateEnabled}#if ($embeddedAttribute.columnLength), length = ${embeddedAttribute.columnLength}#end#if ($embeddedAttribute.columnDefinition), columnDefinition = "${embeddedAttribute.columnDefinition}"#end#if ($embeddedAttribute.columnPrecision), precision = ${embeddedAttribute.columnPrecision}#end#if ($embeddedAttribute.columnScale), scale = ${embeddedAttribute.columnScale}#end))#if($velocityCount != $attribute.type.attributes.size()),#end + +#* *##end + }) +#* *##else @javax.persistence.Column(name = "${attribute.columnName}"#if ($attribute.unique), unique = ${attribute.unique}#end#if (!$attribute.columnNullable), nullable = ${attribute.columnNullable}#end#**#, insertable = ${attribute.insertEnabled}, updatable = ${attribute.updateEnabled}#if ($attribute.columnLength), length = ${attribute.columnLength}#end#if ($attribute.columnDefinition), columnDefinition = "${attribute.columnDefinition}"#end#if ($attribute.columnPrecision), precision = ${attribute.columnPrecision}#end#if ($attribute.columnScale), scale = ${attribute.columnScale}#end) +#* *##end #* *##if (!$attribute.lob && $attribute.lazy) ## ## Only add the fetch type property for LAZY hints - default is EAGER |
From: Vance K. <va...@us...> - 2006-04-26 15:17:40
|
User: vancek Date: 06/04/26 08:16:52 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: extensive refactoring to avoid generating the entity impl src if no business operations are modelled. eliminate static finders from entity class -> finders reside in DAO only, inline with spring cartridge. added NamedQueries and NamedQuery annotations for pre-configured queries. Revision Changes Path 1.25 +52 -147 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.24 retrieving revision 1.25 diff -u -w -r1.24 -r1.25 --- EntityEmbeddable.vsl 24 Apr 2006 02:26:51 -0000 1.24 +++ EntityEmbeddable.vsl 26 Apr 2006 15:16:51 -0000 1.25 @@ -1,5 +1,8 @@ // license-header java merge-point -/* Autogenerated by AndroMDA (Entity.vsl) - do not edit */ +// +// Attention: Generated code! Do not modify by hand! +// Generated by: EntityEmbeddable.vsl in andromda-ejb3-cartridge. +// #if ($stringUtils.isNotBlank($entity.packageName)) package $entity.packageName; #end @@ -11,7 +14,7 @@ ## 2. an abstract class ## ## -#if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass) +#if ($entity.entityImplementationRequired) #**##set ($generatedFile = "${stringUtils.replace($entity.fullyQualifiedEntityEmbeddableName,'.','/')}.java") #else #**##set ($generatedFile = "${stringUtils.replace($entity.fullyQualifiedEntityName,'.','/')}.java") @@ -19,10 +22,10 @@ #set ($identifier = $entity.identifiers.iterator().next()) /** - * Autogenerated POJO EJB#if (!$entity.requiresGeneralizationMapping || $entity.embeddableSuperclass) embeddable/mapped super#end class for ${entity.entityName} containing the + * Autogenerated POJO EJB#if ($entity.entityImplementationRequired) mapped super#end class for ${entity.entityName} containing the * bulk of the entity implementation. * - * This is#if (!$entity.requiresGeneralizationMapping || $entity.embeddableSuperclass) an embeddable/mapped super class and#end autogenerated by AndroMDA using the EJB3 + * This is#if ($entity.entityImplementationRequired) a mapped super class and#end autogenerated by AndroMDA using the EJB3 * cartridge. * * DO NOT MODIFY this class. @@ -30,29 +33,33 @@ $entity.getDocumentation(" * ") * */ -#if (!$entity.requiresGeneralizationMapping || $entity.embeddableSuperclass) +## +## Only set the Entity annotation if it is explicity defined as an embeddable super class +## or business operations exist(implementation is required). +## +#if ($entity.entityImplementationRequired) @javax.persistence.MappedSuperclass #else @javax.persistence.Entity -#end ## ## Include the Table annotation for a base class in single table inheritence hierarchy ## but not in the subclasses. Include in all classes for joined and table per class ## inheritance hierarchies. +## ## If a class is manually specified as an embeddable superclass, add ## the Table annotation to the subclass, not to the base superclass. ## -#if ($entity.requiresGeneralizationMapping && ($entity.embeddableSuperclassGeneralizationExists || $entity.inheritanceTablePerClass || $entity.inheritanceJoined)) +#**##if (!$entity.entityImplementationRequired && (($entity.requiresSpecializationMapping && !$entity.embeddableSuperclass) || ($entity.requiresGeneralizationMapping && ($entity.embeddableSuperclassGeneralizationExists || $entity.inheritanceTablePerClass || $entity.inheritanceJoined)))) @javax.persistence.Table(name = "${entity.tableName}") -#end -#if ($entity.requiresGeneralizationMapping && $entity.listenerEnabled) +#**##end +#**##if ($entity.listenerEnabled) @javax.persistence.EntityListeners({${entity.fullyQualifiedEntityListenerName}.class}) -#end +#**##end ## ## Only include the inheritance related annotations for inheritance mapping ## that doesn't involve embeddable superclass hierarchy. ## -#if ($entity.requiresSpecializationMapping && !$entity.embeddableSuperclass) +#**##if ($entity.requiresSpecializationMapping && !$entity.embeddableSuperclass) @javax.persistence.Inheritance(strategy = javax.persistence.InheritanceType.${entity.inheritanceStrategy}) ## ## Discriminator components only apply to single table mapping strategy @@ -62,17 +69,37 @@ @javax.persistence.DiscriminatorColumn(#if ($entity.discriminatorColumn)name = "${entity.discriminatorColumn}"#set ($argExists = true)#end#if ($entity.discriminatorType)#if ($argExists), #end#**#discriminatorType = javax.persistence.DiscriminatorType.${entity.discriminatorType}#set ($argExists = true)#end#if ($entity.discriminatorColumnDefinition)#if ($argExists), #end#**#columnDefinition = "${entity.discriminatorColumnDefinition}"#set ($argExists = true)#end#if ($entity.discriminatorLength > 0)#if ($argExists), #end#**#length = ${entity.discriminatorLength}#end) @javax.persistence.DiscriminatorValue("${entity.discriminatorValue}") #**##end -#elseif ($entity.requiresGeneralizationMapping && !$entity.embeddableSuperclassGeneralizationExists) +#**##elseif ($entity.requiresGeneralizationMapping && $entity.inheritanceSingleTable) ## -## Only include the DiscriminatorValue annotation for subclasses if the super class -## is NOT an embeddable superclass. +## Only include the DiscriminatorValue annotation for subclasses if +## the inheritance strategy is single table mapping strategy. ## @javax.persistence.DiscriminatorValue("${entity.discriminatorValue}") -#end -#if ($entity.cacheEnabled) +#**##end +#**##if ($entity.cacheEnabled) @org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.${entity.cacheType}) +#**##end +#**##set ($finders = $entity.getQueryOperations(false)) +#**##if (!$finders.empty) +...@ja...dQueries +({ +#* *##if ($entity.genericFinders) + @javax.persistence.NamedQuery(name = "${entity.name}.findAll", query = "select $stringUtils.uncapitalize(${entity.name}) from ${entity.name} AS $stringUtils.uncapitalize(${entity.name})")#if (!$finders.empty),#end + +#* *##end +#* *##foreach ($finder in $finders) + @javax.persistence.NamedQuery(name = "${entity.name}.${finder.name}", query = "${finder.query}")#if($velocityCount != $finders.size()), #end + +#* *##end +}) +#**##else +#* *##if ($entity.genericFinders) +...@ja...dQuery(name = "${entity.name}.findAll", query = "select $stringUtils.uncapitalize(${entity.name}) from ${entity.name} AS $stringUtils.uncapitalize(${entity.name})")#if (!$finders.empty),#end + +#* *##end +#**##end #end -public#if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass) abstract class ${entity.entityEmbeddableName}#else class ${entity.entityName}#end +public#if ($entity.entityImplementationRequired) abstract class ${entity.entityEmbeddableName}#else class ${entity.entityName}#end #if($entity.generalization) extends ${entity.generalization.fullyQualifiedName} @@ -167,7 +194,7 @@ /** * Default empty constructor */ - public #if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass)${entity.entityEmbeddableName}#else${entity.entityName}#end() + public #if ($entity.entityImplementationRequired)${entity.entityEmbeddableName}#else${entity.entityName}#end() { // default null constructor } @@ -186,7 +213,7 @@ * @param $attribute.name Value for the ${attribute.name} property #**##end */ - public #if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass)${entity.entityEmbeddableName}#else${entity.entityName}#end($entity.getAttributesAsList($allAttributes, true, true, false)) + public #if ($entity.entityImplementationRequired)${entity.entityEmbeddableName}#else${entity.entityName}#end($entity.getAttributesAsList($allAttributes, true, true, false)) { #**##if(!$inheritedAttributes.empty) super($entity.getAttributesAsList($inheritedAttributes, false, true, false)); @@ -210,7 +237,7 @@ * @param $relation.otherEnd.name Value for the ${relation.otherEnd.name} relation role #* *##end */ - public #if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass)${entity.entityEmbeddableName}#else${entity.entityName}#end($entity.getAttributesAsList($allAttributes, true, true, false)#if(!$allAttributes.empty), #end#foreach ($relation in $relations)${relation.otherEnd.getterSetterTypeName} $relation.otherEnd.name#if($velocityCount != $relations.size()), #end#end) + public #if ($entity.entityImplementationRequired)${entity.entityEmbeddableName}#else${entity.entityName}#end($entity.getAttributesAsList($allAttributes, true, true, false)#if(!$allAttributes.empty), #end#foreach ($relation in $relations)${relation.otherEnd.getterSetterTypeName} $relation.otherEnd.name#if($velocityCount != $relations.size()), #end#end) { #* *##foreach ($attribute in $transform.filterUpdatableAttributes($instanceAttributes, $entity.compositePrimaryKeyPresent)) ${attribute.setterName}(${attribute.name}); @@ -233,7 +260,7 @@ * @param $attribute Value for the $attribute property #**##end */ - public #if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass)${entity.entityEmbeddableName}#else${entity.entityName}#end(${operation.typedArgumentList}) + public #if ($entity.entityImplementationRequired)${entity.entityEmbeddableName}#else${entity.entityName}#end(${operation.typedArgumentList}) { #**##foreach($attribute in $opArguments) this.${attribute} = $attribute; @@ -247,7 +274,7 @@ * * @param pk Composite primary key */ - public #if (!$entity.requiresGeneralizationMapping && !$entity.embeddableSuperclass)${entity.entityEmbeddableName}#else${entity.entityName}#end(${entity.fullyQualifiedEntityCompositePrimaryKeyName} pk) + public #if ($entity.entityImplementationRequired)${entity.entityEmbeddableName}#else${entity.entityName}#end(${entity.fullyQualifiedEntityCompositePrimaryKeyName} pk) { this.pk = pk; } @@ -670,126 +697,4 @@ #* *##end #**##end #end -#if ($entity.genericFinders) - - // ----------- Generic Finder Methods -------------- - -## -## Do not include the findAll finder for inheriting classes when the -## inheritance strategy is single table. This is defined in the base -## class. -## -## Only render if the findAll finder hasn't been modelled. -## -#**##if ((($entity.inheritanceSingleTable && !$entity.requiresGeneralizationMapping) || !$entity.inheritanceSingleTable) && !$entity.finderFindAllExists) - /** - * Returns the collection of all ${entity.name}s. - * - * @param em javax.persistence.EntityManager - * @return all available ${entity.name} objects - */ -## -## For inheriting classes, replace findAll with findAll${entity.name}s -## - public static java.util.Collection<${entity.name}> findAll#if ($entity.requiresGeneralizationMapping)$stringUtils.capitalize(${entity.name})s#end(javax.persistence.EntityManager em) - { - return em.createQuery("FROM ${entity.name} AS $stringUtils.uncapitalize(${entity.name})").getResultList(); - } - -#**##end -## -## Only include the findByPrimaryKey method if not an inheriting class. -## Classes that inherit from a base class use the primary key identifier -## of the base class. The inheritence relationship is reflected in the -## queries, so queries based on the base/root class are polymorphic. -## -## Do not include the findByPrimaryKey if this bean has a composite -## primary key class. -## -## Only render if the findAll finder hasn't been modelled. -## -#**##if (!$entity.compositePrimaryKeyPresent && !$entity.requiresGeneralizationMapping && !$entity.finderFindByPrimaryKeyExists) -#* *##foreach ($attribute in $entity.getIdentifiers(false)) -#* *##set ($identifierName = $attribute.name) -#* *##set ($identifierType = $attribute.type.fullyQualifiedName) -#* *##set ($identifierTypePrimitive = $attribute.type.primitive) -#* *##if ($attribute.type.primitive) -#* *##set ($identifierTypeWrapperName = $attribute.type.wrapperName) -#* *##end -#* *##end - /** - * Returns the ${entity.name} matching the identifier. - * - * @param em javax.persistence.EntityManager - * @param ${identifierName} the primary key - * @return the ${entity.name} object matching the primary key - */ - public static ${entity.fullyQualifiedEntityName} findByPrimaryKey(javax.persistence.EntityManager em, ${identifierType} ${identifierName}) - { -## If the identifier is a primitive type, use the wrapper class - return em.find(${entity.fullyQualifiedEntityName}.class,#if ($identifierTypePrimitive) new ${identifierTypeWrapperName}(${identifierName})#else ${identifierName}#end); - } -#**##end -#end -#set ($finders = $entity.getQueryOperations(true)) -#if (!$finders.empty) - - // -------- User Defined Finder Methods ------------ - -#**##foreach ($finder in $finders) -#* *##set ($returnType = $finder.returnType.fullyQualifiedName) -#* *##set ($parameterList = $finder.typedArgumentList) -#* *##if ($finder.arguments.empty) -#* *##set ($parameters = "javax.persistence.EntityManager em") -#* *##else -#* *##set ($parameters = "javax.persistence.EntityManager em, ${parameterList}") -#* *##end - /** - * Finder method for ${entity.name} entity using a query. -$finder.getDocumentation(" * ") - * - * @param em javax.persistence.EntityManager -#* *##foreach ($parameter in $finder.arguments) - * @param $parameter.type.fullyQualifiedName ${parameter.name} -#* *##end - * @return $returnType - */ - $finder.visibility static $returnType#if ($finder.returnType.collectionType || $finder.returnType.listType || $finder.returnType.setType || $finder.returnType.mapType)<${entity.name}>#end ${finder.name}($parameters) - { - javax.persistence.Query query = em.createQuery("$finder.query"); -#* *##foreach ($parameter in $finder.arguments) -#* *##set ($index = $velocityCount - 1) -#* *##if ($parameter.firstResult) - query.setFirstResult(${parameter.name}); -#* *##elseif ($parameter.maxResults) - query.setMaxResults(${parameter.name}); -#* *##else -## -## Find the attribute matching the parameter name -## If the parameter type is an enum: -## If -## -#* *##if ($finder.useNamedParameters) - query.setParameter("${parameter.name}",#if ($parameter.type.primitive) new ${parameter.type.wrapperName}(${parameter.name})#else ${parameter.name}#if ($parameter.enumerationTypeOrdinal).ordinal()#elseif ($parameter.enumerationTypeString).name()#end#end#if ($parameter.temporalType), javax.persistence.TemporalType.${parameter.temporalType}#end); -#* *##else - query.setParameter(${index},#if ($parameter.type.primitive) new ${parameter.type.wrapperName}(${parameter.name})#else ${parameter.name}#if ($parameter.enumerationTypeOrdinal).ordinal()#elseif ($parameter.enumerationTypeString).name()#end#end#if ($parameter.temporalType), javax.persistence.TemporalType.${parameter.temporalType}#end); -#* *##end -#* *##end -#* *##end -#* *##if ($finder.useQueryCache && !$entity.useDefaultCacheRegion) - query.setHint("org.hibernate.cacheRegion", "/${entity.fullyQualifiedNamePath}_${finder.name}"); -#* *##end -#* *##if ($stringUtils.equalsIgnoreCase($returnType, "void")) - query.executeUpdate(); -#* *##elseif ($finder.returnType.primitive) - return (($finder.returnType.wrapperName)query.getSingleResult()).${returnType}Value(); -#* *##elseif (!$finder.returnType.collectionType) - return ($returnType)query.getSingleResult(); -#* *##else - return query.getResultList(); -#* *##end - } - -#**##end -#end } \ No newline at end of file |
From: Vance K. <va...@us...> - 2006-04-27 06:47:05
|
User: vancek Date: 06/04/26 23:47:01 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: entityImplementationRequired only checks for availability of business operations. in some circumstances, to determine if an implementation is required, we need to check if the entity is defined as a mapped superclass. if parent class is a mapped superclass, then include named queries from it. fixed fully qualified mapped superclass name if inheriting from mapped superclass. if entity is a mapped superclass then don't add auto generated identifier. Revision Changes Path 1.26 +33 -16 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.25 retrieving revision 1.26 diff -u -w -r1.25 -r1.26 --- EntityEmbeddable.vsl 26 Apr 2006 15:16:51 -0000 1.25 +++ EntityEmbeddable.vsl 27 Apr 2006 06:47:01 -0000 1.26 @@ -14,7 +14,7 @@ ## 2. an abstract class ## ## -#if ($entity.entityImplementationRequired) +#if ($entity.entityImplementationRequired || $entity.embeddableSuperclass) #**##set ($generatedFile = "${stringUtils.replace($entity.fullyQualifiedEntityEmbeddableName,'.','/')}.java") #else #**##set ($generatedFile = "${stringUtils.replace($entity.fullyQualifiedEntityName,'.','/')}.java") @@ -22,10 +22,10 @@ #set ($identifier = $entity.identifiers.iterator().next()) /** - * Autogenerated POJO EJB#if ($entity.entityImplementationRequired) mapped super#end class for ${entity.entityName} containing the + * Autogenerated POJO EJB#if ($entity.entityImplementationRequired || $entity.embeddableSuperclass) mapped super#end class for ${entity.entityName} containing the * bulk of the entity implementation. * - * This is#if ($entity.entityImplementationRequired) a mapped super class and#end autogenerated by AndroMDA using the EJB3 + * This is#if ($entity.entityImplementationRequired || $entity.embeddableSuperclass) a mapped super class and#end autogenerated by AndroMDA using the EJB3 * cartridge. * * DO NOT MODIFY this class. @@ -37,7 +37,7 @@ ## Only set the Entity annotation if it is explicity defined as an embeddable super class ## or business operations exist(implementation is required). ## -#if ($entity.entityImplementationRequired) +#if ($entity.entityImplementationRequired || $entity.embeddableSuperclass) @javax.persistence.MappedSuperclass #else @javax.persistence.Entity @@ -49,7 +49,7 @@ ## If a class is manually specified as an embeddable superclass, add ## the Table annotation to the subclass, not to the base superclass. ## -#**##if (!$entity.entityImplementationRequired && (($entity.requiresSpecializationMapping && !$entity.embeddableSuperclass) || ($entity.requiresGeneralizationMapping && ($entity.embeddableSuperclassGeneralizationExists || $entity.inheritanceTablePerClass || $entity.inheritanceJoined)))) +#**##if (!$entity.entityImplementationRequired && ($entity.requiresSpecializationMapping || ($entity.requiresGeneralizationMapping && ($entity.embeddableSuperclassGeneralizationExists || $entity.inheritanceTablePerClass || $entity.inheritanceJoined)))) @javax.persistence.Table(name = "${entity.tableName}") #**##end #**##if ($entity.listenerEnabled) @@ -59,7 +59,7 @@ ## Only include the inheritance related annotations for inheritance mapping ## that doesn't involve embeddable superclass hierarchy. ## -#**##if ($entity.requiresSpecializationMapping && !$entity.embeddableSuperclass) +#**##if ($entity.requiresSpecializationMapping) @javax.persistence.Inheritance(strategy = javax.persistence.InheritanceType.${entity.inheritanceStrategy}) ## ## Discriminator components only apply to single table mapping strategy @@ -79,7 +79,14 @@ #**##if ($entity.cacheEnabled) @org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.${entity.cacheType}) #**##end +## +## If super class is a mapped superclass, then include named queries from it +## +#**##if ($entity.embeddableSuperclassGeneralizationExists) +#* *##set ($finders = $entity.getQueryOperations(true)) +#**##else #**##set ($finders = $entity.getQueryOperations(false)) +#**##end #**##if (!$finders.empty) @javax.persistence.NamedQueries ({ @@ -99,10 +106,14 @@ #* *##end #**##end #end -public#if ($entity.entityImplementationRequired) abstract class ${entity.entityEmbeddableName}#else class ${entity.entityName}#end +public#if ($entity.entityImplementationRequired || $entity.embeddableSuperclass) abstract class ${entity.entityEmbeddableName}#else class ${entity.entityName}#end -#if($entity.generalization) +#if($entity.requiresGeneralizationMapping) +#**##if($entity.embeddableSuperclassGeneralizationExists) + extends ${entity.generalization.fullyQualifiedEntityEmbeddableName} +#**##else extends ${entity.generalization.fullyQualifiedName} +#**##end #end implements java.io.Serializable #if (!$entity.interfaceAbstractions.empty) @@ -122,9 +133,15 @@ #**##end #end ## -## Only declase instance attributes that are NOT inherited +## Only declase instance attributes that are NOT inherited. +## If a mapped superclass then don't generate auto identifier - but include +## normal defined identifier if one is defined. ## -#set ($attributes = $entity.instanceAttributes) +#if ($entity.embeddableSuperclass && $entity.dynamicIdentifiersPresent) +#**##set ($attributes = $entity.getInstanceAttributes(false, false)) +#else +#**##set ($attributes = $entity.instanceAttributes) +#end #if (!$attributes.empty) // ----------- Attribute Definitions ------------ @@ -194,7 +211,7 @@ /** * Default empty constructor */ - public #if ($entity.entityImplementationRequired)${entity.entityEmbeddableName}#else${entity.entityName}#end() + public #if ($entity.entityImplementationRequired || $entity.embeddableSuperclass)${entity.entityEmbeddableName}#else${entity.entityName}#end() { // default null constructor } @@ -213,7 +230,7 @@ * @param $attribute.name Value for the ${attribute.name} property #**##end */ - public #if ($entity.entityImplementationRequired)${entity.entityEmbeddableName}#else${entity.entityName}#end($entity.getAttributesAsList($allAttributes, true, true, false)) + public #if ($entity.entityImplementationRequired || $entity.embeddableSuperclass)${entity.entityEmbeddableName}#else${entity.entityName}#end($entity.getAttributesAsList($allAttributes, true, true, false)) { #**##if(!$inheritedAttributes.empty) super($entity.getAttributesAsList($inheritedAttributes, false, true, false)); @@ -237,7 +254,7 @@ * @param $relation.otherEnd.name Value for the ${relation.otherEnd.name} relation role #* *##end */ - public #if ($entity.entityImplementationRequired)${entity.entityEmbeddableName}#else${entity.entityName}#end($entity.getAttributesAsList($allAttributes, true, true, false)#if(!$allAttributes.empty), #end#foreach ($relation in $relations)${relation.otherEnd.getterSetterTypeName} $relation.otherEnd.name#if($velocityCount != $relations.size()), #end#end) + public #if ($entity.entityImplementationRequired || $entity.embeddableSuperclass)${entity.entityEmbeddableName}#else${entity.entityName}#end($entity.getAttributesAsList($allAttributes, true, true, false)#if(!$allAttributes.empty), #end#foreach ($relation in $relations)${relation.otherEnd.getterSetterTypeName} $relation.otherEnd.name#if($velocityCount != $relations.size()), #end#end) { #* *##foreach ($attribute in $transform.filterUpdatableAttributes($instanceAttributes, $entity.compositePrimaryKeyPresent)) ${attribute.setterName}(${attribute.name}); @@ -260,7 +277,7 @@ * @param $attribute Value for the $attribute property #**##end */ - public #if ($entity.entityImplementationRequired)${entity.entityEmbeddableName}#else${entity.entityName}#end(${operation.typedArgumentList}) + public #if ($entity.entityImplementationRequired || $entity.embeddableSuperclass)${entity.entityEmbeddableName}#else${entity.entityName}#end(${operation.typedArgumentList}) { #**##foreach($attribute in $opArguments) this.${attribute} = $attribute; @@ -274,7 +291,7 @@ * * @param pk Composite primary key */ - public #if ($entity.entityImplementationRequired)${entity.entityEmbeddableName}#else${entity.entityName}#end(${entity.fullyQualifiedEntityCompositePrimaryKeyName} pk) + public #if ($entity.entityImplementationRequired || $entity.embeddableSuperclass)${entity.entityEmbeddableName}#else${entity.entityName}#end(${entity.fullyQualifiedEntityCompositePrimaryKeyName} pk) { this.pk = pk; } |
From: Vance K. <va...@us...> - 2006-04-30 01:49:04
|
User: vancek Date: 06/04/29 18:48:59 Modified: andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: add new line after constant declarations Revision Changes Path 1.27 +1 -0 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.26 retrieving revision 1.27 diff -u -w -r1.26 -r1.27 --- EntityEmbeddable.vsl 27 Apr 2006 06:47:01 -0000 1.26 +++ EntityEmbeddable.vsl 30 Apr 2006 01:48:59 -0000 1.27 @@ -130,6 +130,7 @@ #**##foreach ($constant in $constants) @javax.persistence.Transient public static final $constant.type.fullyQualifiedName $constant.name = $constant.defaultValue; + #**##end #end ## |