branch develop updated (4941c00 -> 9d44c84)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository topia. See http://git.nuiton.org/topia.git from 4941c00 [jgitflow-maven-plugin]Updating develop poms back to pre merge state new 5f9f2f5 refs #3676 use new topia tag value to generate deterministice foreign key names + use it to generate hibernate mappings new 9d44c84 fixes #3676: Generate foreign key names Merge branch 'feature/3676' into develop The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 9d44c84f9cf8aa2de863526a82c41196062d7174 Merge: 4941c00 5f9f2f5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Apr 21 17:17:33 2015 +0200 fixes #3676: Generate foreign key names Merge branch 'feature/3676' into develop commit 5f9f2f5d30d94290320bdbb0cb7bdb1c88cdf4e5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Apr 21 17:17:25 2015 +0200 refs #3676 use new topia tag value to generate deterministice foreign key names + use it to generate hibernate mappings Summary of changes: .../generator/EntityHibernateMappingGenerator.java | 181 +++++++++++++++------ .../nuiton/topia/generator/TopiaGeneratorUtil.java | 22 ++- .../org/nuiton/topia/generator/TopiaTagValues.java | 12 ++ 3 files changed, 163 insertions(+), 52 deletions(-) -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository topia. See http://git.nuiton.org/topia.git commit 5f9f2f5d30d94290320bdbb0cb7bdb1c88cdf4e5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Apr 21 17:17:25 2015 +0200 refs #3676 use new topia tag value to generate deterministice foreign key names + use it to generate hibernate mappings --- .../generator/EntityHibernateMappingGenerator.java | 181 +++++++++++++++------ .../nuiton/topia/generator/TopiaGeneratorUtil.java | 22 ++- .../org/nuiton/topia/generator/TopiaTagValues.java | 12 ++ 3 files changed, 163 insertions(+), 52 deletions(-) diff --git a/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java b/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java index d622bb0..52e7cd1 100644 --- a/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java +++ b/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java @@ -41,6 +41,7 @@ import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.nuiton.eugene.models.object.ObjectModel; import org.nuiton.eugene.models.object.ObjectModelAssociationClass; import org.nuiton.eugene.models.object.ObjectModelAttribute; import org.nuiton.eugene.models.object.ObjectModelClass; @@ -89,7 +90,7 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { public static final String HIBERNATE_ATTRIBUTE_NOT_NULL = "not-null"; public static final String HIBERNATE_ATTRIBUTE_SCHEMA = "schema"; - + public static final String HIBERNATE_ATTRIBUTE_INDEX = "index"; public static final String HIBERNATE_ATTRIBUTE_UNIQUE = "unique"; @@ -98,6 +99,58 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { public static final String HIBERNATE_ATTRIBUTE_ORDER_BY = "order-by"; + public static final String HIBERNATE_ATTRIBUTE_FOREIGN_KEY = "foreign-key"; + + static class ClassContext { + + private final ObjectModel model; + + private final ObjectModelClass input; + + private final boolean generateForeignKeyNames; + + private final String tableName; + + private final String schema; + + ClassContext(ObjectModel model, ObjectModelClass input) { + this.model = model; + this.input = input; + this.generateForeignKeyNames = TopiaGeneratorUtil.isGenerateForeignKeyNames(input, model); + this.tableName = TopiaGeneratorUtil.getDbName(input); + this.schema = TopiaGeneratorUtil.getDbSchemaNameTagValue(input, model); + } + + public boolean isGenerateForeignKeyNames() { + return generateForeignKeyNames; + } + + public String getTableName() { + return tableName; + } + + public boolean isUseSchema() { + return schema != null; + } + + public String getSchema() { + return schema; + } + + public String getForeignKeyName(String attrColumn) { + return getForeignKeyName(tableName , attrColumn).toLowerCase(); + } + + public String getForeignKeyName(String tableName, String attrColumn) { + return ("fk_" + tableName + "_" + attrColumn).toLowerCase(); + } + + public ObjectModelClass getInput() { + return input; + } + + } + @Override public String getFilenameForClass(ObjectModelClass clazz) { String DOName = TopiaGeneratorUtil.getDOType(clazz, model); @@ -116,6 +169,9 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "classpath://org/hibernate/hibernate-mapping-3.0.dtd"> <hibernate-mapping default-access="field" auto-import="true" package="<%=input.getPackageName()%>"> }*/ + + ClassContext classContext = new ClassContext(model, input); + boolean haveSuper = input.getSuperclasses().size() > 0; // la liste des attributs faisant parti de la clef metier List<ObjectModelAttribute> naturalAttributes = new ArrayList<ObjectModelAttribute>(); @@ -123,16 +179,15 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { List<ObjectModelAttribute> noneNaturalAttributes = new ArrayList<ObjectModelAttribute>(); String clazzDOType = TopiaGeneratorUtil.getDOType(input, model); - String tableName = TopiaGeneratorUtil.getDbName(input); + String tableName = classContext.getTableName(); String isAbstract = BooleanUtils.toStringTrueFalse(input.isAbstract()); String clazzFQN = input.getQualifiedName(); - + String optionalAttributes = ""; - String schema = TopiaGeneratorUtil.getDbSchemaNameTagValue(input, model); - if (schema != null) { - optionalAttributes += "schema=\"" + schema + "\" "; + if (classContext.isUseSchema()) { + optionalAttributes += "schema=\"" + classContext.getSchema() + "\" "; } - + //On précise au proxy de quelle interface hérite l'objet String proxyTagValue = TopiaGeneratorUtil.getProxyInterfaceTagValue(input, model); if (StringUtils.isEmpty(proxyTagValue) || !proxyTagValue.equals("none")) { @@ -177,7 +232,7 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { } /*{ <natural-id<%=mutableStr%>> }*/ - generateAttributes(output, input, naturalAttributes, " "); + generateAttributes(output, classContext, naturalAttributes, " "); /*{ </natural-id> }*/ } @@ -186,7 +241,7 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { }*/ } - generateAttributes(output, input, noneNaturalAttributes, ""); + generateAttributes(output, classContext, noneNaturalAttributes, ""); if (haveSuper) { /*{ </union-subclass> @@ -196,16 +251,16 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { }*/ } - generateDatabaseObjects(output, input, naturalAttributes); - generateDatabaseObjects(output, input, noneNaturalAttributes); + generateDatabaseObjects(output, classContext, naturalAttributes); + generateDatabaseObjects(output, classContext, noneNaturalAttributes); /*{</hibernate-mapping> }*/ } protected void generateDatabaseObjects(Writer output, - ObjectModelClass clazz, - List<ObjectModelAttribute> attributes) throws IOException { + ClassContext classContext, + List<ObjectModelAttribute> attributes) throws IOException { for (ObjectModelAttribute attribute : attributes) { if (!attribute.isNavigable() || @@ -219,9 +274,9 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { continue; } - String indexForeignKeys = + String indexForeignKeys = TopiaGeneratorUtil.getIndexForeignKeys(attribute, model); - + if (StringUtils.isEmpty(indexForeignKeys) || !Boolean.valueOf(indexForeignKeys)) { // no index to put of the attribute. @@ -231,8 +286,8 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { // add database-object to create and drop index // add schema if exist (http://nuiton.org/issues/2052) - String schema = TopiaGeneratorUtil.getDbSchemaNameTagValue(clazz, model); - boolean withSchema = StringUtils.isNotEmpty(schema); + String schema = classContext.getSchema(); + boolean withSchema = classContext.isUseSchema(); String tableName; String propertyName; @@ -271,8 +326,9 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { } } + protected void generateAttributes(Writer output, - ObjectModelClass clazz, + ClassContext classContext, List<ObjectModelAttribute> attributes, String prefix) throws IOException { for (ObjectModelAttribute attr : attributes) { @@ -287,30 +343,31 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { if (!TopiaGeneratorUtil.isNMultiplicity(attr)) { if (attr.getClassifier() != null && TopiaGeneratorUtil.isEntity(attr.getClassifier())) { if (TopiaGeneratorUtil.isNMultiplicity(attr.getReverseMaxMultiplicity()) && !attr.hasAssociationClass()) { - generateHibernateManyToOne(output, attr, prefix); + generateHibernateManyToOne(output, classContext, attr, prefix); } else { - generateHibernateOneToOne(output, attr, prefix); + generateHibernateOneToOne(output, classContext, attr, prefix); } } else { - generateHibernateProperty(output, clazz, attr, prefix); + generateHibernateProperty(output, classContext, attr, prefix); } } else { if (attr.getClassifier() != null && TopiaGeneratorUtil.isEntity(attr.getClassifier())) { if (TopiaGeneratorUtil.isNMultiplicity(attr.getReverseMaxMultiplicity()) && !attr.hasAssociationClass()) { - generateHibernateManyToMany(output, clazz, attr, prefix); + generateHibernateManyToMany(output, classContext, attr, prefix); } else { - generateHibernateOneToMany(output, attr, prefix); + generateHibernateOneToMany(output, classContext, attr, prefix); } } else { - generateHibernateMany(output, attr, prefix); + generateHibernateMany(output, classContext, attr, prefix); } } } } //Attributs pour les classes d'association + ObjectModelClass clazz = classContext.getInput(); if (clazz instanceof ObjectModelAssociationClass) { - ObjectModelAssociationClass assoc = (ObjectModelAssociationClass)clazz; + ObjectModelAssociationClass assoc = (ObjectModelAssociationClass) clazz; for (ObjectModelAttribute attr : assoc.getParticipantsAttributes()) { if (attr != null) { @@ -325,7 +382,11 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { String attrType = getType(attr, true); String lazy = generateFromTagValue(HIBERNATE_ATTRIBUTE_LAZY, TopiaGeneratorUtil.getLazyTagValue(attr)); String attrColumn = TopiaGeneratorUtil.getDbName(attr); -/*{<%=prefix%> <many-to-one name="<%=attrName%>" class="<%=attrType%>" <%=lazy%>column="<%=attrColumn%>" node="<%=attrName%>/@topiaId" <%=notNull%>/> + String foreignKeyName =""; + if (classContext.isGenerateForeignKeyNames()) { + foreignKeyName = " " + generateFromTagValue(HIBERNATE_ATTRIBUTE_FOREIGN_KEY, classContext.getForeignKeyName(attrColumn)).trim(); + } +/*{<%=prefix%> <many-to-one name="<%=attrName%>" class="<%=attrType%>" <%=lazy%>column="<%=attrColumn%>" node="<%=attrName%>/@topiaId" <%=notNull%><%=foreignKeyName%>/> }*/ // } //Ne sert plus grâce à l'utilisation de la navigabilité @@ -400,7 +461,7 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { } protected void generateHibernateProperty(Writer output, - ObjectModelClass clazz, + ClassContext classContext, ObjectModelAttribute attr, String prefix) throws IOException { String attrType = getType(attr); @@ -421,10 +482,8 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { attrType = attrType.trim().substring(0, attrType.trim().length()-2); String optionalAttributes = ""; - //String schema = TopiaGeneratorUtil.getDbSchemaNameTagValue(attr.getClassifier(), model); - String schema = TopiaGeneratorUtil.getDbSchemaNameTagValue(clazz, model); - if (schema != null) { - optionalAttributes += generateFromTagValue(HIBERNATE_ATTRIBUTE_SCHEMA, schema); + if (classContext.isUseSchema()) { + optionalAttributes += generateFromTagValue(HIBERNATE_ATTRIBUTE_SCHEMA, classContext.getSchema()); } if (TopiaGeneratorUtil.hasIndexedStereotype(attr)) { @@ -480,7 +539,7 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { // add length attribute if required String lengthTagValue = TopiaGeneratorUtil.getLengthTagValue(attr); if (!StringUtils.isEmpty(lengthTagValue)) { - + optionalAttributes += generateFromTagValue(HIBERNATE_ATTRIBUTE_LENGTH, lengthTagValue); } @@ -493,7 +552,7 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { boolean noSpecifiedColumn = columnNames == null || columnNames.length == 0; if (noSpecifiedColumn) { - + String attrColumn = TopiaGeneratorUtil.getDbName(attr); if (columnAttributes.isEmpty()) { @@ -544,7 +603,7 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { }*/ } } else { - + // there is a colum name mapping specified, must use it //FIXME tchemit 2010-12-29 Really don't know how to apply columnAttributes for multi-columns... /*{<%=optionalAttributes%>> @@ -561,21 +620,23 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { } protected void generateHibernateOneToOne(Writer output, + ClassContext classContext, ObjectModelAttribute attr, String prefix) throws IOException { // boolean accessField = hasUnidirectionalRelationOnAbstractType(attr.getReverseAttribute(), model); /// *{ <one-to-one name="<%=getName(attr)%>" class="<%=getType(attr)%>"<%=(TopiaGeneratorUtil.notEmpty(attr.getTagValue(TopiaGeneratorUtil.TAG_LENGTH))?(" length=\"" + attr.getTagValue(TopiaGeneratorUtil.TAG_LENGTH) + "\""):"")%><%=((attr.isComposite() || attr.hasAssociationClass())?" cascade=\"delete\"":"")%><%=((accessField)?" access=\"field\"":"")%> node="<%=getName(attr)%>/@topiaId" /> //} */ - + // for hibernate many-to-one with unique="true" => one-to-one // but if it is one-to-zero-or-one unique contraints is violated // with null values boolean unique = TopiaGeneratorUtil.isOneMultiplicity(attr); - generateHibernateManyToOne(output, attr, unique, prefix); + generateHibernateManyToOne(output, classContext, attr, unique, prefix); } protected void generateHibernateOneToMany(Writer output, + ClassContext classContext, ObjectModelAttribute attr, String prefix) throws IOException { boolean needsIndex = TopiaGeneratorUtil.hasIndexedStereotype(attr); @@ -601,16 +662,21 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { if (isInverse) { inverse = "inverse=\"true\" "; } + String foreignKeyAttribute = ""; + if (classContext.isGenerateForeignKeyNames()) { + String columnName = TopiaGeneratorUtil.getDbName(attr); + foreignKeyAttribute = " " + generateFromTagValue(HIBERNATE_ATTRIBUTE_FOREIGN_KEY, classContext.getForeignKeyName(columnName)).trim(); + } if (needsIndex) { /*{<%=prefix%> <<%=collType%> name="<%=attrName%>" <%=inverse%><%=lazy%><%=cascade%>node="<%=attrName%>"> -<%=prefix%> <key column="<%=reverseAttrDBName%>"/> +<%=prefix%> <key column="<%=reverseAttrDBName%>"<%=foreignKeyAttribute%>/> <%=prefix%> <list-index column="<%=reverseAttrDBName%>_idx"/> <%=prefix%> <one-to-many class="<%=attrType%>" node="topiaId"/> <%=prefix%> </<%=collType%>> }*/ - }else { + } else { /*{<%=prefix%> <<%=collType%> name="<%=attrName%>" <%=inverse%><%=orderBy%><%=fetch%><%=lazy%><%=cascade%>node="<%=attrName%>"> -<%=prefix%> <key column="<%=reverseAttrDBName%>"/> +<%=prefix%> <key column="<%=reverseAttrDBName%>"<%=foreignKeyAttribute%>/> <%=prefix%> <one-to-many class="<%=attrType%>" node="topiaId"/> <%=prefix%> </<%=collType%>> }*/ @@ -647,7 +713,8 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { return result; } - protected void generateHibernateMany(Writer output, + protected void generateHibernateMany(Writer output, + ClassContext classContext, ObjectModelAttribute attr, String prefix) throws IOException { boolean needsIndex = TopiaGeneratorUtil.hasIndexedStereotype(attr); @@ -656,9 +723,13 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { String collType = TopiaGeneratorUtil.getNMultiplicityHibernateType(attr); String lazy = generateFromTagValue(HIBERNATE_ATTRIBUTE_LAZY, TopiaGeneratorUtil.getLazyTagValue(attr)); String attrColumn = TopiaGeneratorUtil.getDbName(attr); + String foreignKeyAttribute = ""; + if (classContext.isGenerateForeignKeyNames()) { + foreignKeyAttribute = " " + HIBERNATE_ATTRIBUTE_FOREIGN_KEY + "=\"" + classContext.getTableName() + "_" + attrColumn + "\""; + } /*{<%=prefix%> <<%=collType%> name="<%=attrName%>" <%=lazy%>node="<%=attrName%>"> -<%=prefix%> <key column="OWNER"/> +<%=prefix%> <key column="OWNER"<%=foreignKeyAttribute%>/> }*/ if (needsIndex) { /*{<%=prefix%> <list-index/> @@ -670,12 +741,14 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { } protected void generateHibernateManyToOne(Writer output, + ClassContext classContext, ObjectModelAttribute attr, String prefix) throws IOException { - generateHibernateManyToOne(output, attr, false, prefix); + generateHibernateManyToOne(output, classContext, attr, false, prefix); } protected void generateHibernateManyToOne(Writer output, + ClassContext classContext, ObjectModelAttribute attr, boolean isUnique, String prefix) throws IOException { @@ -686,6 +759,10 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { if (attr.isComposite() || attr.hasAssociationClass()) { /*{cascade="delete" }*/ } + if (classContext.isGenerateForeignKeyNames()) { + String foreignKeyName = generateFromTagValue(HIBERNATE_ATTRIBUTE_FOREIGN_KEY, classContext.getForeignKeyName(attrColumn)); +/*{<%=foreignKeyName%>}*/ + } // Pour le test suivant, on verifie d'abord que l'attribut a un reverse. // S'il n'en a pas, cela signifie qu'il ne s'agit pas d'un entite // (au sens stereotype entity), donc a donc pas besoin de faire un access=field. @@ -707,7 +784,7 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { } protected void generateHibernateManyToMany(Writer output, - ObjectModelClass clazz, + ClassContext classContext, ObjectModelAttribute attr, String prefix) throws IOException { // On ne met le inverse="true" uniquement pour un seul coté de la relation. @@ -716,7 +793,7 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { boolean isInverse = attr.isNavigable() && attr.getReverseAttribute().isNavigable(); //isInverse |= !Util.isFirstAttribute(attr); //isInverse = false; // 20070117 poussin: pour du many, jamais de inverse - + // Modification FD-2010-04-01 : // Le tagvalue "inverse" permet de spécifier qui possède le // inverse="true". Il est impératif de l'utiliser sur les deux @@ -751,23 +828,27 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { String reverseAttrDBName = TopiaGeneratorUtil.getReverseDbName(attr); String optionalAttributes=""; - //String schema = TopiaGeneratorUtil.getDbSchemaNameTagValue(attr.getClassifier(), model); - String schema = TopiaGeneratorUtil.getDbSchemaNameTagValue(clazz, model); - if (schema != null) { - optionalAttributes += generateFromTagValue(HIBERNATE_ATTRIBUTE_SCHEMA, schema); + if (classContext.isUseSchema()) { + optionalAttributes += generateFromTagValue(HIBERNATE_ATTRIBUTE_SCHEMA, classContext.getSchema()); } if (!optionalAttributes.isEmpty()) { optionalAttributes = " " + optionalAttributes.trim(); } + String foreignKeyName = ""; + String reverseForeignKeyName = ""; + if (classContext.isGenerateForeignKeyNames()) { + foreignKeyName = " " + generateFromTagValue(HIBERNATE_ATTRIBUTE_FOREIGN_KEY, classContext.getForeignKeyName(tableName, reverseAttrDBName)).trim(); + reverseForeignKeyName = " " + generateFromTagValue(HIBERNATE_ATTRIBUTE_FOREIGN_KEY, classContext.getForeignKeyName(tableName, attrColumn)).trim(); + } /*{<%=prefix%> <<%=collType%> name="<%=attrName%>" table="<%=tableName%>" <%=inverse%><%=lazy%><%=cascade%> node="<%=attrName%>"<%=optionalAttributes%>> -<%=prefix%> <key column="<%=reverseAttrDBName%>"/> +<%=prefix%> <key column="<%=reverseAttrDBName%>"<%=foreignKeyName%>/> }*/ if (needsIndex) { /*{<%=prefix%> <list-index column="<%=reverseAttrDBName%>_idx"/> }*/ } -/*{<%=prefix%> <many-to-many class="<%=attrType%>" column="<%=attrColumn%>" <%=orderBy%>node="topiaId"/> +/*{<%=prefix%> <many-to-many class="<%=attrType%>" column="<%=attrColumn%>" <%=orderBy%>node="topiaId"<%=reverseForeignKeyName%>/> <%=prefix%> </<%=collType%>> }*/ } diff --git a/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaGeneratorUtil.java b/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaGeneratorUtil.java index 8eabb93..fed5160 100644 --- a/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaGeneratorUtil.java +++ b/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaGeneratorUtil.java @@ -1951,11 +1951,11 @@ public class TopiaGeneratorUtil extends JavaGeneratorUtil { boolean generate = StringUtils.isNotEmpty(tagValue) && Boolean.valueOf(tagValue); return generate; } - + /** * Obtain the value of the {@link TopiaTagValues#TAG_DO_NOT_GENERATE_READ_LISTENERS} * tag value on the given model or classifier. - * + * * It will first look on the model, and then in the given classifier. * * @param model model to seek @@ -1969,5 +1969,23 @@ public class TopiaGeneratorUtil extends JavaGeneratorUtil { return value != null && "true".equals(value); } + + /** + * Obtain the value of the {@link TopiaTagValues#TAG_DO_NOT_GENERATE_READ_LISTENERS} + * tag value on the given model or classifier and returns {@code true} if the tag value was found and value {@code true}. + * + * It will first look on the model, and then in the given classifier. + * + * @param model model to seek + * @param classifier classifier to seek + * @return {@code true} if tag value was found on classifier or model and his value is {@code true}, otherwise {@code false}. + * @see TopiaTagValues#TAG_GENERATE_FOREIGN_KEY_NAMES + * @since 2.10 + */ + public static boolean isGenerateForeignKeyNames(ObjectModelClassifier classifier, ObjectModel model) { + String value = findTagValue(TopiaTagValues.TAG_GENERATE_FOREIGN_KEY_NAMES, classifier, model); + return value != null && "true".equals(value); + } + } // TopiaGeneratorUtil diff --git a/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaTagValues.java b/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaTagValues.java index e3ebc6c..57569c6 100644 --- a/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaTagValues.java +++ b/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaTagValues.java @@ -477,6 +477,18 @@ public class TopiaTagValues extends TagValueDefinitionProvider { public static final String TAG_INDEX_FOREIGN_KEYS = "indexForeignKeys"; /** + * Tag to generate deterministic foreign key names in hibernate mapping files. + * <p/> + * + * @see TopiaGeneratorUtil#isGenerateForeignKeyNames(ObjectModelClassifier, ObjectModel) + * @since 2.10 + */ + @TagValueDefinition(target = {ObjectModel.class, ObjectModelClassifier.class}, + documentation = "To generate deterministic foreign keys names in hibernate mappings.") + public static final String TAG_GENERATE_FOREIGN_KEY_NAMES = "generateForeignKeyNames"; + + + /** * Tag to specify if we want to add an "id" property in DTO generated by * {@link EntityDTOTransformer}. * <p/> -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository topia. See http://git.nuiton.org/topia.git commit 9d44c84f9cf8aa2de863526a82c41196062d7174 Merge: 4941c00 5f9f2f5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Apr 21 17:17:33 2015 +0200 fixes #3676: Generate foreign key names Merge branch 'feature/3676' into develop .../generator/EntityHibernateMappingGenerator.java | 181 +++++++++++++++------ .../nuiton/topia/generator/TopiaGeneratorUtil.java | 22 ++- .../org/nuiton/topia/generator/TopiaTagValues.java | 12 ++ 3 files changed, 163 insertions(+), 52 deletions(-) -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm