From: Eric C <ecr...@us...> - 2006-03-08 04:16:00
|
User: ecrutchfield Date: 06/03/07 20:15:59 Added: andromda-nhibernate/src/main/resources/templates/nhibernate nhibernate.hbm.xml.vsl NHibernateEmbeddedValueImpl.vsl NHibernateEmbeddedValue.vsl NHibernateEnumeration.vsl NHibernateEntityImplManual.vsl NHibernateEntity.vsl NHibernateEntityImpl.vsl nhibernate.cfg.xml.vsl nhibernate.cs.vm nhibernate.hbm.xml.vm andromda-nhibernate/src/main/java/org/andromda/cartridges/nhibernate/metafacades HibernateFinderMethodArgumentLogicImpl.java HibernateMetafacadeUtils.java HibernateAssociationEndLogicImpl.java HibernateAssociationLogicImpl.java HibernateServiceLogicImpl.java HibernateServiceOperationLogicImpl.java HibernateGlobals.java HibernateTypeLogicImpl.java HibernateFinderMethodLogicImpl.java HibernateEntityAttributeLogicImpl.java HibernateEntityLogicImpl.java HibernateEnumerationLogicImpl.java HibernateEmbeddedValueLogicImpl.java andromda-nhibernate/src/site site.xml andromda-nhibernate/src/main/resources/META-INF/andromda metafacades.xml profile.xml namespace.xml cartridge.xml andromda-nhibernate pom.xml .cvsignore andromda-nhibernate/src/main/uml HibernateMetafacadeModel.xml.zip andromda-nhibernate/src/site/xdoc index.xml howto1.xml andromda-nhibernate/conf/test andromda.xml andromda-nhibernate/src/test/expected cartridge-output.zip andromda-nhibernate/src/test/uml HibernateCartridgeTestModel.xml.zip andromda-nhibernate/src/test/mappings MergeMappings.xml andromda-nhibernate/src/main/java/org/andromda/cartridges/nhibernate HibernateUtils.java HibernateProfile.java Log: add nhibernate cartridge Revision Changes Path 1.1 cartridges/andromda-nhibernate/src/main/resources/templates/nhibernate/nhibernate.hbm.xml.vsl Index: nhibernate.hbm.xml.vsl =================================================================== #parse("templates/nhibernate/nhibernate.hbm.xml.vm") #set ($generatedFile = "${entity.packagePath}/${entity.entityName}.hbm.xml") <?xml version="1.0" encoding="$xmlEncoding"?> <!-- Name: ${entity.entityName}.hbm.xml license-header java merge-point Attention: Generated code! Do not modify by hand! Generated by: nhibernate.hbm.xml.vsl in andromda-nhibernate-cartridge. --> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-cascade="$entity.hibernateDefaultCascade"> <class name="$entity.fullyQualifiedEntityImplementationName, ${coreAssemblyName}" table="$entity.tableName" dynamic-insert="$entity.dynamicInsert" dynamic-update="$entity.dynamicUpdate" lazy="$entity.lazy"#if ($entity.hibernateProxy) proxy="$entity.fullyQualifiedEntityImplementationName"#end> #if($hibernateEnableCache.equalsIgnoreCase("true")) <cache usage="$entity.hibernateCacheType" /> #end ## **** Generate <id> **** #if (!$entity.identifiers.empty) #set ($identifier = $entity.identifiers.iterator().next()) #end <id name="${stringUtils.upperCamelCaseName($identifier.name)}" type="$identifier.type.fullyQualifiedHibernateType" unsaved-value="$identifier.type.javaNullString"> <column name="$identifier.columnName" sql-type="$identifier.sqlType"/> <generator class="$entity.hibernateGeneratorClass"> #if ($entity.sequenceHibernateGeneratorClass) <param name="sequence">${entity.tableName}${sequenceIdentifierSuffix}</param> #elseif ($entity.foreignHibernateGeneratorClass) <param name="property">${stringUtils.upperCamelCaseName($entity.parentEnd.name)}</param> #end </generator> </id> ## **** Generate <discriminator> **** #if (!$entity.specializations.empty && $entity.hibernateInheritanceClass) <discriminator column="$entity.hibernateDiscriminatorColumn" type="$entity.hibernateDiscriminatorType"/> #end ## **** Generate <version> **** #if ($stringUtils.isNotBlank($entity.hibernateVersionProperty)) <version name="$entity.hibernateVersionProperty" type="Int32" column="$entity.hibernateVersionProperty"/> #end ## **** If super inheritance is 'interface', render super properties etc **** #foreach ($generalization in $entity.allGeneralizations) #if($generalization.mappingRequiresSuperProperties) #renderPropertiesAndAssociations($generalization "" ) #end #end ## **** render the properties and associations (if any) **** #renderPropertiesAndAssociations($entity "" ) ## **** render the subclass elements if class or subclass strategy. **** #if ($entity.requiresSpecializationMapping) #foreach ($entity in $entity.specializations) #renderSubClass($entity) #end## foreach #end## ($entity.requiresMappingSpecialization) </class> </hibernate-mapping> 1.1 cartridges/andromda-nhibernate/src/main/resources/templates/nhibernate/NHibernateEmbeddedValueImpl.vsl Index: NHibernateEmbeddedValueImpl.vsl =================================================================== #set ($generatedFile = "${embeddedValue.packagePath}/${embeddedValue.implementationName}.cs") // Name: ${embeddedValue.implementationName}.cs // license-header cs merge-point // // This is only generated once! It will never be overwritten. // You can (and have to!) safely modify it by hand. using System; #if ($stringUtils.isNotBlank($embeddedValue.packageName)) namespace $embeddedValue.packageName { #end /// <summary> /// @see $embeddedValue.fullyQualifiedName /// </summary> public#if ($embeddedValue.abstract) abstract#end class $embeddedValue.implementationName : $embeddedValue.fullyQualifiedName { #foreach ($operation in $embeddedValue.operations) /// <summary> /// @see ${embeddedValue.fullyQualifiedName}#${operation.getSignature(false)} /// </summary> $operation.visibility override $operation.returnType.fullyQualifiedName $operation.signature { //TODO: implement $operation.visibility $operation.returnType.fullyQualifiedName $operation.signature #if ($operation.returnTypePresent) return $operation.returnType.javaNullString; #else throw new NotImplementedException("${embeddedValue.fullyQualifiedName}.${operation.signature} Not implemented!"); #end } #end } #if ($stringUtils.isNotBlank($embeddedValue.packageName)) } #end 1.1 cartridges/andromda-nhibernate/src/main/resources/templates/nhibernate/NHibernateEmbeddedValue.vsl Index: NHibernateEmbeddedValue.vsl =================================================================== #set ($generatedFile = "${embeddedValue.packagePath}/${embeddedValue.name}.cs") // Name: ${embeddedValue.name}.cs // license-header cs merge-point // // Attention: Generated code! Do not modify by hand! // Generated by: HibernateEmbeddedValue.vsl in andromda-nhibernate-cartridge. using System; #if ($stringUtils.isNotBlank($embeddedValue.packageName)) namespace $embeddedValue.packageName { #end /// <summary> $embeddedValue.getDocumentation(" /// ") /// </summary> public abstract class $embeddedValue.name #if($embeddedValue.generalization) : $embeddedValue.generalization.fullyQualifiedName #end { // ----- Attributes ----- #foreach ($attribute in $embeddedValue.attributes) private $attribute.getterSetterTypeName $attribute.name; #end // ----- Constructors ----- /// <summary> /// Creates a new instance of {@link ${embeddedValue.name}} /// taking all properties. /// </summary> #set ($parenthesis = "(") #if ($embeddedValue.attributes.empty) #set ($parenthesis = "()") #end public static $embeddedValue.name newInstance${parenthesis} #foreach ($attribute in $embeddedValue.attributes) $attribute.getterSetterTypeName ${attribute.name}#if($velocityCount != $embeddedValue.attributes.size()),#else) #end #end { $embeddedValue.implementationName obj = new ${embeddedValue.implementationName}(); #foreach ($attribute in $embeddedValue.attributes) obj.${attribute.name} = ${attribute.name}; #end obj.initialize(); return obj; } /// <summary> /// Creates a new instance from other $embeddedValue.name instance. /// </summary> public static ${embeddedValue.name} newInstance($embeddedValue.name otherObject) { if (otherObject != null) { return newInstance( #foreach ($attribute in $embeddedValue.attributes) otherObject.${attribute.name}#if($velocityCount != $embeddedValue.attributes.size()),#else); #end #end } return null; } protected ${embeddedValue.name}() { } /// <summary> /// Hook for initializing the object in the subclass /// </summary> protected void initialize() { } // ----- Accessors ----- #foreach ($attribute in $embeddedValue.attributes) #set ($typeName = $attribute.getterSetterTypeName) /// <summary> $attribute.getDocumentation(" /// ") #if ($embeddedValue.immutable) /// protected setter, if subclass methods need to normalize the $embeddedValue.name #end /// </summary> #if ($embeddedValue.immutable) public $typeName ${stringUtils.upperCamelCaseName($attribute.name)} { get { return $attribute.name; } } protected void ${attribute.setterName}($attribute.getterSetterTypeName $attribute.name) { this.${attribute.name} = $attribute.name; } #else public $typeName ${stringUtils.upperCamelCaseName($attribute.name)} { get { return $attribute.name; } set { this.$attribute.name = value; } } #end #end #foreach ($operation in $embeddedValue.operations) #set ($returnType = $operation.returnType) #set ($signature = $operation.signature) /// <summary> $operation.getDocumentation(" /// ") /// </summary> $operation.visibility abstract $returnType.fullyQualifiedName $signature; #end /// <summary> /// Indicates if the argument is of the same type and all attributes are equal. /// </summary> #renderEqualsMethod($embeddedValue) /// <summary> /// Returns a hash code based on class attributes. /// </summary> #renderHashCodeMethod($embeddedValue $embeddedValue.attributes) } #if ($stringUtils.isNotBlank($embeddedValue.packageName)) } #end 1.1 cartridges/andromda-nhibernate/src/main/resources/templates/nhibernate/NHibernateEnumeration.vsl Index: NHibernateEnumeration.vsl =================================================================== // license-header java merge-point // // Attention: Generated code! Do not modify by hand! // Generated by: HibernateEnumeration.vsl in andromda-nhibernate-cartridge. // #set ($generatedFile = "${stringUtils.replace($enumeration.packageName, '.', '/')}/${enumeration.enumerationName}.cs") #if ($stringUtils.isNotBlank($enumeration.packageName)) package $enumeration.packageName; #end import ${hibernateUtils.hibernatePackage}.HibernateException; import java.sql.Types; import java.sql.ResultSet; import java.sql.PreparedStatement; import java.sql.SQLException; /** $enumeration.getDocumentation(" * ") */ public final class $enumeration.enumerationName extends $enumeration.name implements java.io.Serializable, java.lang.Comparable, ${hibernateUtils.hibernateUserTypePackage}.UserType { private static final int[] SQL_TYPES = {Types.VARCHAR}; /** * Default constructor. Hibernate needs the default constructor * to retrieve an instance of the enum from a JDBC resultset. * The instance will be converted to the correct enum instance * in {@link #nullSafeGet(java.sql.ResultSet, java.lang.String[], java.lang.Object)}. */ public ${enumeration.enumerationName}() : base() { } /** * @see ${hibernateUtils.hibernateUserTypePackage}.UserType#sqlTypes() */ public int[] sqlTypes() { return SQL_TYPES; } /** * @see ${hibernateUtils.hibernateUserTypePackage}.UserType#deepCopy(java.lang.Object) */ public Object deepCopy(Object value) throws HibernateException { // Enums are immutable - nothing to be done to deeply clone it return value; } /** * @see ${hibernateUtils.hibernateUserTypePackage}.UserType#isMutable() */ public boolean isMutable() { // Enums are immutable return false; } /** * @see ${hibernateUtils.hibernateUserTypePackage}.UserType#equals(java.lang.Object, java.lang.Object) */ public boolean equals(Object x, Object y) throws HibernateException { return (x == y) || (x != null && y != null && y.equals(x)); } /** * @see ${hibernateUtils.hibernateUserTypePackage}.UserType#returnedClass() */ public Class returnedClass() { return ${enumeration.name}.class; } /** * @see ${hibernateUtils.hibernateUserTypePackage}.UserType#nullSafeGet(java.sql.ResultSet, java.lang.String[], java.lang.Object) */ public Object nullSafeGet(ResultSet resultSet, String[] values, Object owner) throws HibernateException, SQLException { #if ($enumeration.literalType.primitive) #set ($valueAssignment = "(($enumeration.literalType.wrapperName)resultSet.getObject(values[0])).${enumeration.literalType.fullyQualifiedName}Value()") #else #set ($valueAssignment = "($enumeration.literalType.fullyQualifiedName)resultSet.getObject(values[0])") #end final $enumeration.literalType.fullyQualifiedName value = $valueAssignment; return resultSet.wasNull() ? null : ${enumeration.fromOperationName}(value); } /** * @see ${hibernateUtils.hibernateUserTypePackage}.UserType#nullSafeSet(java.sql.PreparedStatement, java.lang.Object, int) */ public void nullSafeSet(PreparedStatement statement, Object value, int index) throws HibernateException, SQLException { if (value == null) { statement.setNull(index, Types.VARCHAR); } else { #if ($enumeration.literalType.primitive) #set ($typeName = $enumeration.literalType.wrapperName) #else #set ($typeName = $enumeration.literalType.fullyQualifiedName) #end statement.setObject(index, ${typeName}.valueOf(java.lang.String.valueOf(value))); } } #if ($hibernateVersion == "3") /** * @see ${hibernateUtils.hibernateUserTypePackage}.UserType#replace(Object original, Object target, Object owner) */ public Object replace(Object original, Object target, Object owner) { return original; } /** * @see ${hibernateUtils.hibernateUserTypePackage}.UserType#assemble(java.io.Serializable cached, Object owner) */ public Object assemble(java.io.Serializable cached, Object owner) { return cached; } /** * @see ${hibernateUtils.hibernateUserTypePackage}.UserType#assemble(Object value) */ public java.io.Serializable disassemble(Object value) { return (java.io.Serializable)value; } /** * @see ${hibernateUtils.hibernateUserTypePackage}.UserType#assemble(Object value) */ public int hashCode(Object x) { return x.hashCode(); } #end } 1.1 cartridges/andromda-nhibernate/src/main/resources/templates/nhibernate/NHibernateEntityImplManual.vsl Index: NHibernateEntityImplManual.vsl =================================================================== #set ($generatedFile = "${entity.packagePath}/${entity.entityImplementationName}.cs") // Name: ${entity.entityImplementationName}.cs // license-header cs merge-point // // This is only generated once! It will never be overwritten. // You can (and have to!) safely modify it by hand. using System; #if ($stringUtils.isNotBlank($entity.packageName)) namespace $entity.packageName { #end /// <summary> /// <see cref="$entity.fullyQualifiedEntityName"/> /// </summary> [Serializable] public#if ($entity.abstract) abstract#end class $entity.entityImplementationName : $entity.fullyQualifiedEntityName { #foreach ($operation in $entity.businessOperations) /// <summary> /// <see cref="${entity.fullyQualifiedEntityName}#${operation.getSignature(false)}"/> /// </summary> #set ($abstract = $entity.abstract && $operation.abstract) $operation.visibility#if ($abstract) abstract#end override $operation.returnType.fullyQualifiedName $operation.signature#if ($abstract && !$operation.exceptionsPresent);#end #if (!$abstract) { //TODO: implement $operation.visibility $operation.returnType.fullyQualifiedName $operation.signature #if ($operation.returnTypePresent) return $operation.returnType.javaNullString; #else throw new NotImplementedException("${entity.fullyQualifiedName}.${operation.signature} Not implemented!"); #end } #end #end } #if ($stringUtils.isNotBlank($entity.packageName)) } #end 1.1 cartridges/andromda-nhibernate/src/main/resources/templates/nhibernate/NHibernateEntity.vsl Index: NHibernateEntity.vsl =================================================================== #set ($generatedFile = "${entity.packagePath}/${entity.entityName}.cs") // Name: ${entity.entityName}.cs // license-header cs merge-point // // Attention: Generated code! Do not modify by hand! // Generated by: HibernateEntity.vsl in andromda-nhibernate-cartridge. using System; #if ($stringUtils.isNotBlank($entity.packageName)) namespace $entity.packageName { #end /// <summary> $entity.getDocumentation(" /// ") /// </summary> [Serializable] public abstract class $entity.entityName #if($entity.generalization) : $entity.generalization.fullyQualifiedEntityImplementationName #end { #if ($stringUtils.isNotBlank($entity.hibernateVersionProperty)) #set ($versionProperty = $entity.hibernateVersionProperty) #set ($versionPropertyCapitalized = $stringUtils.capitalize($entity.hibernateVersionProperty)) /// <summary> /// Version property managed by Hibernate. /// </summary> private int $versionProperty; public int get$versionPropertyCapitalized() { return this.$versionProperty; } private void set$versionPropertyCapitalized (int $versionProperty) { this.$versionProperty = $versionProperty; } #end // ----- Attributes and Associations ----- ## **** Generate attribute **** #foreach ( $attribute in $entity.attributes ) #set ($typeName = $attribute.type.fullyQualifiedName) #if ($attribute.containsEmbeddedObject) #set ($typeName = $attribute.type.fullyQualifiedEntityName) #end private $typeName $attribute.name; #end ## **** Generate associations **** #foreach ($associationEnd in $entity.associationEnds) #set ($target = $associationEnd.otherEnd) #if ($target.navigable || ($associationEnd.child && $entity.foreignHibernateGeneratorClass)) #if ($target.many) private $target.getterSetterTypeName $target.name = $target.collectionTypeImplementation; #else private $target.getterSetterTypeName $target.name; #end #end #end // ----- Accessors ----- ## **** Generate accessors for attributes **** #foreach ( $attribute in $entity.attributes ) #set ($typeName = $attribute.type.fullyQualifiedName) #if ($attribute.containsEmbeddedObject) #set ($typeName = $attribute.type.fullyQualifiedEntityName) #end /// <summary> $attribute.getDocumentation(" /// ") /// </summary> $attribute.visibility virtual $typeName ${stringUtils.upperCamelCaseName($attribute.name)} { get { return $attribute.name; } set { this.$attribute.name = value; } } #end ## **** Generate accessors for associations **** #foreach ($associationEnd in $entity.associationEnds) #set ($target = $associationEnd.otherEnd) #if ($target.navigable || ($associationEnd.child && $entity.foreignHibernateGeneratorClass)) /// <summary> $target.getDocumentation(" /// ") /// </summary> public virtual $target.getterSetterTypeName ${stringUtils.upperCamelCaseName($target.name)} { get { return $target.name; } set { this.$target.name = value; } } #end #end // ----- Abstract Methods ----- #foreach ($operation in $entity.businessOperations) #set ($returnType = $operation.returnType) #set ($signature = $operation.signature) /// <summary> $operation.getDocumentation(" /// ") /// </summary> $operation.visibility abstract $returnType.fullyQualifiedName $signature; #end // ----- Helper Methods ----- #if ($generateEntityEqualsAndHashCode.equalsIgnoreCase('true')) #set ($identifiers = $entity.getIdentifiers(false)) /// <summary> #if ($identifiers.empty) /// This entity does not have any identifiers #if ($entity.generalization) /// but since it extends the <code>$entity.generalization.fullyQualifiedEntityImplementationName</code> class /// it will simply delegate the call up there. /// /// @see $entity.generalization.fullyQualifiedEntityName#Equals(Object) #else /// and is not extending any other entity, /// so this method will only return <code>true</code> if the argument reference and <code>this</code> /// refer to the same object. #end #else #if ($entity.generalization) /// Returns <code>true</code> if the argument is a $entity.entityName instance and all identifiers for this entity /// equal the identifiers of the argument entity. The <code>equals</code> method of the parent entity /// will also need to return <code>true</code>. Returns <code>false</code> otherwise. /// /// @see $entity.generalization.fullyQualifiedEntityName#Equals(Object) #else /// Returns <code>true</code> if the argument is a $entity.entityName instance and all identifiers for this entity /// equal the identifiers of the argument entity. Returns <code>false</code> otherwise. #end #end /// </summary> #renderEqualsMethod($entity) /// <summary> #if ($identifiers.empty) /// This entity does not have any identifiers #if ($entity.generalization) /// but since it extends the <code>$entity.generalization.fullyQualifiedEntityImplementationName</code> class /// it will simply delegate the call up there. /// /// @see $entity.generalization.fullyQualifiedEntityName#GetHashCode() #else /// and is not extending any other entity, /// so this method will only take the identifiers of this entity into account when calculating the hash code. #end #else #if ($entity.generalization) /// Returns a hash code based on this entity's identifiers and the hash code of the parent entity. /// /// @see $entity.generalization.fullyQualifiedEntityName#GetHashCode() #else /// Returns a hash code based on this entity's identifiers. #end #end /// </summary> #renderHashCodeMethod($entity $identifiers) #end #if (!$entity.abstract) /// <summary> /// Returns a String representation of this Entity /// </summary> public override String ToString() { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("$entity.name: "); #set ($attributes = $entity.getAttributes(true,true)) #foreach($attribute in $attributes) sb.Append("$attribute.name").Append('=').Append(${stringUtils.upperCamelCaseName($attribute.name)})#if($velocityCount != $attributes.size()).Append(", ")#end; #end return sb.ToString(); } #end #if (!$entity.abstract && ($visualStudioVersion != "2003")) #set ($concreteBaseClass = $entity.generalization && !$entity.generalization.abstract) /// <summary> /// Constructs new instances of {@link ${entity.fullyQualifiedName}}. /// </summary> public static#if ($concreteBaseClass) new#end class Factory { /// <summary> /// Constructs a new instance of {@link ${entity.fullyQualifiedName}}. /// </summary> public static $entity.fullyQualifiedName newInstance() { return new ${entity.fullyQualifiedEntityImplementationName}(); } } #end // HibernateEntity.vsl merge-point } #if (!$entity.abstract && ($visualStudioVersion == "2003")) #set ($concreteBaseClass = $entity.generalization && !$entity.generalization.abstract) /// <summary> /// Constructs new instances of {@link ${entity.fullyQualifiedName}}. /// </summary> public class ${entity.Name}Factory { /// <summary> /// Constructs a new instance of {@link ${entity.fullyQualifiedName}}. /// </summary> public static $entity.fullyQualifiedName newInstance() { return new ${entity.fullyQualifiedEntityImplementationName}(); } } #end #if ($stringUtils.isNotBlank($entity.packageName)) } #end 1.1 cartridges/andromda-nhibernate/src/main/resources/templates/nhibernate/NHibernateEntityImpl.vsl Index: NHibernateEntityImpl.vsl =================================================================== #set ($generatedFile = "${entity.packagePath}/${entity.entityImplementationName}.cs") // Name: ${entity.entityImplementationName}.cs // license-header cs merge-point // // Attention: Generated code! Do not modify by hand! // Generated by: HibernateEntityImpl.vsl in andromda-nhibernate-cartridge. using System; #if ($stringUtils.isNotBlank($entity.packageName)) namespace $entity.packageName { #end /// <summary> /// @see $entity.fullyQualifiedEntityName /// </summary> [Serializable] public#if ($entity.abstract) abstract#end class $entity.entityImplementationName : $entity.fullyQualifiedEntityName { } #if ($stringUtils.isNotBlank($entity.packageName)) } #end 1.1 cartridges/andromda-nhibernate/src/main/resources/templates/nhibernate/nhibernate.cfg.xml.vsl Index: nhibernate.cfg.xml.vsl =================================================================== <?xml version="1.0" encoding="$xmlEncoding"?> <!-- Attention: Generated code! Do not modify by hand! Generated by: hibernate.cfg.xml.vsl in andromda-nhibernate-cartridge. --> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd"> <hibernate-configuration> <session-factory> <!-- properties --> #if ($stringUtils.isNotBlank($driver)) <property name="connection.driver_class">$driver</property> #end #if ($stringUtils.isNotBlank($username)) <property name="connection.username">$username</property> #end #if ($stringUtils.isNotBlank($password)) <property name="connection.password">$password</property> #end #if ($stringUtils.isNotBlank($dataSource)) <property name="connection.datasource">$dataSource</property> #end #if ($stringUtils.isNotBlank($connectionUrl)) <property name="connection.url">$connectionUrl</property> #end #if ($stringUtils.isNotBlank($hibernatePoolSize)) <property name="pool.size">$hibernatePoolSize</property> #end #if ($stringUtils.isNotBlank($hibernateTransactionManagerStrategy)) <property name="transaction.manager.strategy">$hibernateTransactionManagerStrategy</property> #end #if ($stringUtils.isNotBlank($hibernateUserTransactionName)) <property name="jta.UserTransaction">$hibernateUserTransactionName</property> #end #if ($stringUtils.isNotBlank($hibernateTransactionFactoryClass)) <property name="transaction.factory_class">$hibernateTransactionFactoryClass</property> #end #if ($stringUtils.isNotBlank($hibernateTransactionManagerLookup)) <property name="transaction.manager_lookup_class">$hibernateTransactionManagerLookup</property> #end #if ($stringUtils.isNotBlank($hibernateUseOuterJoin)) <property name="use_outer_join">$hibernateUseOuterJoin</property> #end #if ($stringUtils.isNotBlank($hibernateShowSql)) <property name="show_sql">$hibernateShowSql</property> #end #if ($stringUtils.isNotBlank($hibernateJndiName)) <property name="session_factory_name">$hibernateJndiName</property> #end #if ($stringUtils.isNotBlank($hibernateDialect)) <property name="dialect">$hibernateDialect</property> #end #if ($stringUtils.isNotBlank($hibernateDefaultSchema)) <property name="default_schema">$hibernateDefaultSchema</property> #end #if ($stringUtils.isNotBlank($hibernateMaxFetchDepth)) <property name="max_fetch_depth">$hibernateMaxFetchDepth</property> #end #if ($stringUtils.isNotBlank($hibernateJdbcFetchSize)) <property name="jdbc.fetch_size">$hibernateJdbcFetchSize</property> #end #if ($stringUtils.isNotBlank($hibernateJdbcBatchSize)) <property name="jdbc.batch_size">$hibernateJdbcBatchSize</property> #end #if ($stringUtils.isNotBlank($hibernateJdbcUseScrollableResultSet)) <property name="jdbc.use_scrollable_resultset">$hibernateJdbcUseScrollableResultSet</property> #end #if ($stringUtils.isNotBlank($hibernateJdbcUseStreamsForBinary)) <property name="use_streams_for_binary">$hibernateJdbcUseStreamsForBinary</property> #end #if ($stringUtils.isNotBlank($hibernateHbm2DDLAuto)) <property name="hibernate.hbm2ddl.auto">$hibernateHbm2DDLAuto</property> #end #if ($stringUtils.isNotBlank($hibernateQuerySubstitutions)) <property name="hibernate.query.substitutions">$hibernateQuerySubstitutions</property> #end #if ($stringUtils.isNotBlank($hibernateEnableCache)) <property name="hibernate.cache.use_query_cache">$hibernateEnableCache</property> #end #if ($stringUtils.isNotBlank($hibernateCacheProvider)) <property name="hibernate.cache.provider_class">$hibernateCacheProvider</property> #end #if ($stringUtils.isNotBlank($hibernateQueryCacheFactory)) <property name="hibernate.cache.query_cache_factory">$hibernateQueryCacheFactory</property> #end <!-- mapping files --> #foreach($entity in $entities) <mapping resource="${entity.packagePath}/${entity.entityName}.hbm.xml"/> #end </session-factory> </hibernate-configuration> 1.1 cartridges/andromda-nhibernate/src/main/resources/templates/nhibernate/nhibernate.cs.vm Index: nhibernate.cs.vm =================================================================== ## ## This macro will render the Equals() method. ## If an entity is rendered, only the identifiers are compared. ## If an embedded value is renderer, then all attributes are compared. ## #macro (renderEqualsMethod $class) #if ($class.class.name == "org.andromda.cartridges.nhibernate.metafacades.HibernateEntityLogicImpl") #set ($isEntity = true) #set ($attributeSet = $class.getIdentifiers(false)) #else #set ($isEntity = false) #set ($attributeSet = $class.attributes) #end public override bool Equals(Object obj) { #if ($attributeSet.empty) return base.Equals(obj); #else if (this == obj) { return true; } if (GetType() != obj.GetType()) { return false; } $class.name that = ($class.name)obj; #foreach ($attribute in $attributeSet) #set ($attrType = $attribute.type) #set ($attrName = ${stringUtils.upperCamelCaseName($attribute.name)}) #if ($attrType.primitive) #if ($isEntity) if (this.$attrName == 0 || that.$attrName == 0 || this.$attrName != that.$attrName) { return false; } #else if (this.$attrName != that.$attrName) { return false; } #end #elseif ($attrType.enumeration) if (this.$attrName != that.$attrName) { return false; } #elseif ($attrType.arrayType) if (!cs.util.Arrays.equals(this.$attrName, that.$attrName)) { return false; } #else if (this.$attrName == null || that.$attrName == null || !this.${attrName}.Equals(that.$attrName)) { return false; } #end #end return true; #end } #end ## ## This macro will render the GetHashCode() method ## If an entity is rendered, the attributeSet consists of the identifiers, ## if an value type is renderer, the attributeSet consists of all attributes ## #macro (renderHashCodeMethod $class $attributeSet) public override int GetHashCode() { #if ($attributeSet.empty) return base.GetHashCode(); #else #if ($class.generalization) int hashCode = base.GetHashCode(); #else int hashCode = 0; #end #foreach ($attribute in $attributeSet) #set ($attrType = $attribute.type) #set ($attrName = ${stringUtils.upperCamelCaseName($attribute.name)}) #if ($attribute.getterSetterTypeName == "bool") hashCode = 29 * hashCode + (${attrName} ? 1 : 0); #elseif ($attribute.getterSetterTypeName == "System.Guid") hashCode = 29 * hashCode + ${attrName}.GetHashCode(); #elseif ($attrType.arrayType) // arrays are not part of the hashCode calculation #elseif ($attrType.primitive || $attrType.enumeration) hashCode = 29 * hashCode + (int)${attrName}; #else hashCode = 29 * hashCode + (${attrName} == null ? 0 : ${attrName}.GetHashCode()); #end## if #end## foreach return hashCode; #end## $attributeSet.empty } #end 1.1 cartridges/andromda-nhibernate/src/main/resources/templates/nhibernate/nhibernate.hbm.xml.vm Index: nhibernate.hbm.xml.vm =================================================================== ## ## This macro will render any properties and associations. ## $entity can be of type HibernateEntity or HibernateEmbeddedValue ## #macro (renderPropertiesAndAssociations $entity $paramSqlPrefix) ## **** Generate attributes **** #foreach ($attribute in $entity.attributes) #if (!$attribute.identifier) #set ($fullyQualifiedPropertyType = $attribute.type.fullyQualifiedHibernateType) #if ($attribute.type.enumeration) #set ($fullyQualifiedPropertyType = "$attribute.type.fullyQualifiedHibernateType, ${commonAssemblyName}") #end #if ($attribute.containsEmbeddedObject) <component name="$stringUtils.upperCamelCaseName($attribute.name)" class="${attribute.type.packageName}.${attribute.type.implementationName}, ${coreAssemblyName}"> ## render the properties of the embedded type #set ($sqlPrefix = $attribute.columnName) #renderPropertiesAndAssociations($attribute.type $sqlPrefix) </component> #elseif($attribute.formula) <property name="$stringUtils.upperCamelCaseName($attribute.name)" type="$fullyQualifiedPropertyType" formula="$attribute.formula" /> #else <property name="$stringUtils.upperCamelCaseName($attribute.name)" type="$fullyQualifiedPropertyType"#if(!$attribute.insertEnabled) insert="false"#end#if(!$attribute.updateEnabled) update="false"#end> ## do not specify sql-type for enumerations. NHibernate prefers to do it based on the underlying enum type. <column name="$attribute.concatColumnName($paramSqlPrefix, $attribute.columnName)" not-null="$attribute.required" unique="$attribute.unique"#if(!$attribute.type.enumeration) sql-type="$attribute.sqlType"#end#if($attribute.columnIndex) index="$attribute.columnIndex"#end/> </property> #end #end #end ## **** Generate associations **** #foreach ($sourceEnd in $entity.associationEnds) #set ($otherEnd = $sourceEnd.otherEnd) #if ($otherEnd.navigable) #if ($sourceEnd.one2One) #if ($sourceEnd.one2OnePrimary || (!$sourceEnd.navigable && !$entity.foreignHibernateGeneratorClass)) #if ($otherEnd.type.foreignHibernateGeneratorClass) <one-to-one name="$stringUtils.upperCamelCaseName($otherEnd.name)" class="$otherEnd.type.fullyQualifiedEntityImplementationName, ${coreAssemblyName}" outer-join="$otherEnd.outerJoin"#if ($otherEnd.hibernateCascade) cascade="$otherEnd.hibernateCascade"#end/> #else <many-to-one name="$stringUtils.upperCamelCaseName($otherEnd.name)" class="$otherEnd.type.fullyQualifiedEntityImplementationName, ${coreAssemblyName}" foreign-key="$otherEnd.foreignKeyConstraintName" outer-join="$otherEnd.outerJoin"#if ($otherEnd.hibernateCascade) cascade="$otherEnd.hibernateCascade"#end#if($otherEnd.columnIndex) index="$otherEnd.columnIndex"#end> <column name="$otherEnd.columnName" not-null="$otherEnd.required" sql-type="$otherEnd.sqlType" unique="true"/> </many-to-one> #end #else #if ($entity.foreignHibernateGeneratorClass) <one-to-one name="$stringUtils.upperCamelCaseName($otherEnd.name)" class="$otherEnd.type.fullyQualifiedEntityImplementationName, ${coreAssemblyName}" foreign-key="$otherEnd.foreignKeyConstraintName" outer-join="$otherEnd.outerJoin"#if ($otherEnd.hibernateCascade) cascade="$otherEnd.hibernateCascade"#end constrained="true"/> #else <one-to-one name="$stringUtils.upperCamelCaseName($otherEnd.name)" class="$otherEnd.type.fullyQualifiedEntityImplementationName, ${coreAssemblyName}" outer-join="$otherEnd.outerJoin" property-ref="$stringUtils.upperCamelCaseName($sourceEnd.name)"#if ($otherEnd.hibernateCascade) cascade="$otherEnd.hibernateCascade"#end/> #end #end #end #if ($sourceEnd.one2Many) #if ($otherEnd.set || $otherEnd.map) <$otherEnd.collectionType name="$stringUtils.upperCamelCaseName($otherEnd.name)" order-by="$otherEnd.orderByColumns" lazy="$otherEnd.lazy" outer-join="$otherEnd.outerJoin" inverse="$otherEnd.hibernateInverse"#if ($otherEnd.hibernateCascade) cascade="$otherEnd.hibernateCascade"#end#if ($otherEnd.whereClause) where="$otherEnd.whereClause"#end#if ($stringUtils.isNotBlank($otherEnd.sortType)) sort="$otherEnd.sortType"#end> #elseif ($otherEnd.bag) <$otherEnd.collectionType name="$stringUtils.upperCamelCaseName($otherEnd.name)" order-by="$otherEnd.orderByColumns" lazy="$otherEnd.lazy" outer-join="$otherEnd.outerJoin" inverse="$otherEnd.hibernateInverse"#if ($otherEnd.hibernateCascade) cascade="$otherEnd.hibernateCascade"#end#if ($otherEnd.whereClause) where="$otherEnd.whereClause"#end> #elseif ($otherEnd.list) <$otherEnd.collectionType name="$stringUtils.upperCamelCaseName($otherEnd.name)" lazy="$otherEnd.lazy" outer-join="$otherEnd.outerJoin" inverse="$otherEnd.hibernateInverse"#if ($otherEnd.hibernateCascade) cascade="$otherEnd.hibernateCascade"#end#if ($otherEnd.whereClause) where="$otherEnd.whereClause"#end> #end #if(($hibernateEnableCache.equalsIgnoreCase("true")) && ($hibernateEnableAssociationsCache.equalsIgnoreCase("true"))) <cache usage="$sourceEnd.association.hibernateCacheType" /> #end <key foreign-key="$sourceEnd.foreignKeyConstraintName"> <column name="$sourceEnd.columnName" sql-type="$sourceEnd.sqlType"/> </key> #if ($otherEnd.indexedCollection) <index column="$otherEnd.collectionIndexName"#if($otherEnd.map) type="$otherEnd.collectionIndexType"#end/> #end <one-to-many class="$otherEnd.type.fullyQualifiedEntityImplementationName, ${coreAssemblyName}"/> </$otherEnd.collectionType> #elseif ($sourceEnd.many2One) <many-to-one name="$stringUtils.upperCamelCaseName($otherEnd.name)" class="$otherEnd.type.fullyQualifiedEntityImplementationName, ${coreAssemblyName}" outer-join="$otherEnd.outerJoin"#if ($otherEnd.hibernateCascade) cascade="$otherEnd.hibernateCascade"#end foreign-key="$otherEnd.foreignKeyConstraintName"#if($otherEnd.columnIndex) index="$otherEnd.columnIndex"#end> <column name="$otherEnd.columnName" not-null="$otherEnd.required" sql-type="$otherEnd.sqlType"/> </many-to-one> #elseif ($sourceEnd.many2Many) <$otherEnd.collectionType name="$stringUtils.upperCamelCaseName($otherEnd.name)" table="$otherEnd.association.tableName" order-by="$sourceEnd.orderByColumns" outer-join="$otherEnd.outerJoin" lazy="$otherEnd.lazy" inverse="$otherEnd.hibernateInverse"#if ($otherEnd.hibernateCascade) cascade="$otherEnd.hibernateCascade"#end#if ($otherEnd.whereClause) where="$otherEnd.whereClause"#end> <key foreign-key="$sourceEnd.foreignKeyConstraintName"> <column name="$sourceEnd.columnName" sql-type="$sourceEnd.sqlType"/> </key> <many-to-many class="$otherEnd.type.fullyQualifiedEntityImplementationName, ${coreAssemblyName}" foreign-key="$otherEnd.foreignKeyConstraintName"> <column name="$otherEnd.columnName" sql-type="$otherEnd.sqlType"#if($otherEnd.columnIndex) index="$otherEnd.columnIndex"#end/> </many-to-many> </$otherEnd.collectionType> #end #end #end #end ## ## This macro will render any sub mappings elements for the given $entity. ## #macro (renderSubClass $entity) ## Should only get get invoked for inheritance class or subclass. <$entity.mappingClassName name="$entity.fullyQualifiedEntityImplementationName, ${coreAssemblyName}"#if($entity.tableRequired) table="$entity.tableName"#else discriminator-value="$entity.entityImplementationName"#end lazy="$entity.lazy"#if($entity.hibernateProxy) proxy="$entity.fullyQualifiedEntityImplementationName"#end dynamic-insert="$entity.dynamicInsert" dynamic-update="$entity.dynamicUpdate"> #if($entity.subclassKeyColumn) <key foreign-key="${entity.tableName}_INHERITANCE_FKC"> <column name="$entity.subclassKeyColumn" sql-type="$identifier.sqlType"/> </key> #end #renderPropertiesAndAssociations($entity "") #foreach ($subentity in $entity.specializations) #renderSubClass($subentity) #end </$entity.mappingClassName> #end 1.1 cartridges/andromda-nhibernate/src/main/java/org/andromda/cartridges/nhibernate/metafacades/HibernateFinderMethodArgumentLogicImpl.java Index: HibernateFinderMethodArgumentLogicImpl.java =================================================================== package org.andromda.cartridges.nhibernate.metafacades; import org.andromda.metafacades.uml.ClassifierFacade; /** * MetafacadeLogic implementation for * org.andromda.cartridges.nhibernate.metafacades.HibernateFinderMethodArgument. * * @see org.andromda.cartridges.nhibernate.metafacades.HibernateFinderMethodArgument */ public class HibernateFinderMethodArgumentLogicImpl extends HibernateFinderMethodArgumentLogic { // ---------------- constructor ------------------------------- public HibernateFinderMethodArgumentLogicImpl( Object metaObject, String context) { super(metaObject, context); } /** * Defines if specific setters methods will be created for primitive types * and dates */ private static final String USE_SPECIALIZED_SETTERS = "hibernateQueryUseSpecializedSetters"; /** * @see org.andromda.cartridges.nhibernate.metafacades.HibernateFinderMethodArgument#getQueryArgumentNameSetter() */ protected java.lang.String handleGetQueryArgumentNameSetter() { StringBuffer setterName = new StringBuffer(); boolean specializedSetters = Boolean.valueOf(String.valueOf(this.getConfiguredProperty(USE_SPECIALIZED_SETTERS))).booleanValue(); ClassifierFacade classifier = this.getType(); if (classifier != null) { if (specializedSetters) { if (classifier.isPrimitive()) { setterName.append("set" + classifier.getWrapperName().replaceAll("(.)*\\.", "")); } else if (classifier.isDateType() || classifier.isStringType()) { setterName.append("set" + classifier.getName()); } else { setterName.append("setParameter"); } } else { setterName.append("setParameter"); } if (classifier.isCollectionType()) { setterName.append("List"); } } return setterName.toString(); } } 1.1 cartridges/andromda-nhibernate/src/main/java/org/andromda/cartridges/nhibernate/metafacades/HibernateMetafacadeUtils.java Index: HibernateMetafacadeUtils.java =================================================================== package org.andromda.cartridges.nhibernate.metafacades; import java.util.Collection; import org.andromda.cartridges.nhibernate.HibernateProfile; import org.andromda.core.common.ExceptionUtils; import org.andromda.metafacades.uml.ClassifierFacade; import org.andromda.metafacades.uml.FilteredCollection; import org.andromda.metafacades.uml.ModelElementFacade; import org.andromda.metafacades.uml.OperationFacade; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.Predicate; import org.apache.commons.lang.StringUtils; /** * Contains utilities for use with Hibernate metafacades. * * @author Chad Brandon */ class HibernateMetafacadeUtils { /** * Gets the view type for the passed in <code>classifier</code>. If the * view type can be retrieved from the <code>classifier</code>, then that * is used, otherwise the <code>defaultViewType</code> is returned. * * @return String the view type name. */ static String getViewType( ClassifierFacade classifier, String defaultViewType) { final String methodName = "HibernateMetafacadeUtils.getViewType"; ExceptionUtils.checkNull(methodName, "classifer", classifier); String viewType = null; if (classifier.hasStereotype(HibernateProfile.STEREOTYPE_SERVICE)) { String viewTypeValue = (String)classifier.findTaggedValue(HibernateProfile.TAGGEDVALUE_EJB_VIEWTYPE); // if the view type wasn't found, search all super classes if (StringUtils.isEmpty(viewTypeValue)) { viewType = (String)CollectionUtils.find( classifier.getAllGeneralizations(), new Predicate() { public boolean evaluate(Object object) { return ((ModelElementFacade)object).findTaggedValue( HibernateProfile.TAGGEDVALUE_EJB_VIEWTYPE) != null; } }); } if (StringUtils.isNotEmpty(viewTypeValue)) { viewType = viewTypeValue; } } if (StringUtils.isEmpty(viewType)) { viewType = defaultViewType; } return viewType.toLowerCase(); } /** * Creates a fully qualified name from the given <code>packageName</code>, * <code>name</code>, and <code>suffix</code>. * * @param packageName the name of the model element package. * @param name the name of the model element. * @param suffix the suffix to append. * @return the new fully qualified name. */ static String getFullyQualifiedName( String packageName, String name, String suffix) { StringBuffer fullyQualifiedName = new StringBuffer(StringUtils.trimToEmpty(packageName)); if (StringUtils.isNotBlank(packageName)) { fullyQualifiedName.append('.'); } fullyQualifiedName.append(StringUtils.trimToEmpty(name)); fullyQualifiedName.append(StringUtils.trimToEmpty(suffix)); return fullyQualifiedName.toString(); } /** * filters all static operations */ static java.util.Collection filterBusinessOperations(Collection operations) { Collection businessOperations = new FilteredCollection(operations) { public boolean evaluate(Object object) { return !((OperationFacade)object).isStatic(); } }; return businessOperations; } } 1.1 cartridges/andromda-nhibernate/src/main/java/org/andromda/cartridges/nhibernate/metafacades/HibernateAssociationEndLogicImpl.java Index: HibernateAssociationEndLogicImpl.java =================================================================== package org.andromda.cartridges.nhibernate.metafacades; import java.util.ArrayList; import java.util.Collection; import org.andromda.cartridges.nhibernate.HibernateProfile; import org.andromda.metafacades.uml.ClassifierFacade; import org.andromda.metafacades.uml.EntityAssociationEnd; import org.andromda.metafacades.uml.EntityMetafacadeUtils; import org.andromda.metafacades.uml.TypeMappings; import org.andromda.metafacades.uml.UMLMetafacadeProperties; import org.andromda.metafacades.uml.UMLProfile; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; /** * MetafacadeLogic implementation for * org.andromda.cartridges.nhibernate.metafacades.HibernateAssociationEnd. * * @see org.andromda.cartridges.nhibernate.metafacades.HibernateAssociationEnd */ public class HibernateAssociationEndLogicImpl extends HibernateAssociationEndLogic { public HibernateAssociationEndLogicImpl( Object metaObject, String context) { super(metaObject, context); } /** * Value for set */ private static final String COLLECTION_TYPE_SET = "set"; /** * Value for map */ private static final String COLLECTION_TYPE_MAP = "map"; /** * Value for bags */ private static final String COLLECTION_TYPE_BAG = "bag"; /** * Value for list */ private static final String COLLECTION_TYPE_LIST = "list"; /** * Value for collections */ private static final String COLLECTION_TYPE_COLLECTION = "collection"; /** * Stores the valid collection types */ private static final Collection collectionTypes = new ArrayList(); static { collectionTypes.add(COLLECTION_TYPE_SET); collectionTypes.add(COLLECTION_TYPE_MAP); collectionTypes.add(COLLECTION_TYPE_BAG); collectionTypes.add(COLLECTION_TYPE_LIST); collectionTypes.add(COLLECTION_TYPE_COLLECTION); } /** * Stores the property indicating whether or not composition should define * the eager loading strategy. */ private static final String COMPOSITION_DEFINES_EAGER_LOADING = "compositionDefinesEagerLoading"; /** * Stores the default outerjoin setting for this association end. */ private static final String PROPERTY_ASSOCIATION_END_OUTERJOIN = "hibernateAssociationEndOuterJoin"; /** * Stores the default collection index name. */ private static final String COLLECTION_INDEX_NAME = "associationEndCollectionIndexName"; /** * Stores the default collection index type. */ private static final String COLLECTION_INDEX_TYPE = "associationEndCollectionIndexType"; /** * Stores the value of the cascade behavior when modeling an aggregation. */ private static final String HIBERNATE_AGGREGATION_CASCADE = "hibernateAggregationCascade"; /** * Stores the value of the cascade behavior when modeling a composition. */ private static final String HIBERNATE_COMPOSITION_CASCADE = "hibernateCompositionCascade"; /** * @see org.andromda.cartridges.nhibernate.metafacades.HibernateEntityAssociationEnd#isOne2OnePrimary() */ protected boolean handleIsOne2OnePrimary() { return (this.isOne2One() && (this.isAggregation() || this.isComposition())); } /** * @see org.andromda.metafacades.uml.AssociationEndFacade#getGetterSetterTypeName() */ public String getGetterSetterTypeName() { String getterSetterTypeName = super.getGetterSetterTypeName(); if (!this.isMany()) { ClassifierFacade type = this.getType(); if (type instanceof HibernateEntity) { final String typeName = ((HibernateEntity)type).getFullyQualifiedEntityName(); if (StringUtils.isNotEmpty(typeName)) { getterSetterTypeName = typeName; } } } if (this.isMany()) { final boolean specificInterfaces = Boolean.valueOf( ObjectUtils.toString(this.getConfiguredProperty(HibernateGlobals.SPECIFIC_COLLECTION_INTERFACES))) .booleanValue(); final TypeMappings mappings = this.getLanguageMappings(); if (mappings != null) { if (this.isMap()) { getterSetterTypeName = mappings.getTo(UMLProfile.MAP_TYPE_NAME); } else if (specificInterfaces) { if (this.isSet()) { getterSetterTypeName = mappings.getTo(UMLProfile.SET_TYPE_NAME); } else if (this.isList()) { getterSetterTypeName = mappings.getTo(UMLProfile.LIST_TYPE_NAME); } } else { getterSetterTypeName = ObjectUtils.toString(this.getConfiguredProperty(HibernateGlobals.DEFAULT_COLLECTION_INTERFACE)); } } else { getterSetterTypeName = ObjectUtils.toString(this.getConfiguredProperty(HibernateGlobals.DEFAULT_COLLECTION_INTERFACE)); } } return getterSetterTypeName; } /** * @see org.andromda.metafacades.uml.AssociationEndFacade#isLazy() */ protected boolean handleIsLazy() { String lazyString = (String)findTaggedValue(HibernateProfile.TAGGEDVALUE_HIBERNATE_LAZY); boolean lazy = true; if (lazyString == null) { // check whether or not composition defines eager loading is turned // on boolean compositionDefinesEagerLoading = Boolean.valueOf(String.valueOf(this.getConfiguredProperty(COMPOSITION_DEFINES_EAGER_LOADING))) .booleanValue(); if (compositionDefinesEagerLoading) { lazy = !this.getOtherEnd().isComposition(); } } else { lazy = Boolean.valueOf(lazyString).booleanValue(); } return lazy; } /** * calculates the hibernate cascade attribute of this association end. * * @return null if no relevant cascade attribute to deliver * @see org.andromda.cartridges.nhibernate.metafacades.HibernateEntityAssociationEnd#getHibernateCascade() */ protected String handleGetHibernateCascade() { String cascade = null; final String individualCascade = (String)findTaggedValue(HibernateProfile.TAGGEDVALUE_HIBERNATE_CASCADE); if ((individualCascade != null) && (individualCascade.length() > 0)) { cascade = individualCascade; } else if (this.isChild()) // other end is a composition { if (StringUtils.isBlank(this.getHibernateCompositionCascade())) { cascade = HibernateGlobals.HIBERNATE_CASCADE_DELETE; final Object type = this.getType(); if (type != null && type instanceof HibernateEntity) { HibernateEntity entity = (HibernateEntity)type; final String defaultCascade = entity.getHibernateDefaultCascade(); if (defaultCascade.equalsIgnoreCase(HibernateGlobals.HIBERNATE_CASCADE_SAVE_UPDATE) || defaultCascade.equalsIgnoreCase(HibernateGlobals.HIBERNATE_CASCADE_ALL)) { if (this.isMany()) { cascade = HibernateGlobals.HIBERNATE_CASCADE_ALL_DELETE_ORPHAN; } else { cascade = HibernateGlobals.HIBERNATE_CASCADE_ALL; } } } } else { cascade = this.getHibernateCompositionCascade(); } } else if (this.isCompos... [truncated message content] |