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; } |