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