branch feature/3452 updated (314c55b -> 928fa63)
This is an automated email from the git hooks/post-receive script. New change to branch feature/3452 in repository topia. See http://git.nuiton.org/topia.git discards 314c55b Improve (see #3674) and fix (see #3675) (when using dbName on reverse attribute) the name of generated index (refs #3452) discards f72b535 For each entity of the model, generate a indexes.ddl file (refs #3452) adds 02493a4 [jgitflow-maven-plugin]updating develop poms to master versions to avoid merge conflicts adds 12f74a3 [jgitflow-maven-plugin]updating poms for branch '3.0-beta-15' with snapshot versions adds abb9a56 Add missing file headers adds b9eb825 [jgitflow-maven-plugin]updating poms for branch'release/3.0-beta-15' with non-snapshot versions adds ca138cf Merge branch 'release/3.0-beta-15' adds 8faa34e Merge branch 'master' into develop adds 95f5804 [jgitflow-maven-plugin]Updating develop poms back to pre merge state adds c2fa911 Introduce TopiaConfiguration with two implementation (bean and properties backed), introduce HibernateTopiaMigrationService, remove obsolete method on TopiaService, rewrite HibernateProvider#newConfiguration to remove all unused tricks, change some signatures to use Set instead of arrays adds 50b2e13 Adding some entry method in Builder adds 2bf5628 fix NPE adds 87b6e04 refs #2892 Generate ApplicationContext contructor based on TopiaConfiguration adds f2169a5 fix build except migration engine test adds 858464b Introduce JdbcConfiguration contract, use it when appropriate, make topia-service-flyway build adds 0fe85a4 use JdbcHelper in tests adds 48b0242 Fix build of topia flyway service adds b70dfa1 Fix build of topia migration service adds fc608df Remove TopiaSchemaHelper class which content has been moved into TopiaItMappingTopiaApplicationContext#createSchema() adds a261bc0 Review some builder method names adds cd45d60 Move configuration in properties reading in builder, refactor BeanTopiaConfiguration to extends BeanJdbcConfiguration adds 9134582 Deprecate everything in TopiaConfigurationConstants adds e9195eb Introduce HibernateAvailableSettings adds 2e409ec Implements a method to convert TopiaConfiguration to Map adds 3a3b569 Convention on builders adds 2da54fd Use interface AvailableSettings where possible instead of a Hibernate subclass adds 3e5ee7d Deprecate TopiaH2Util and move API to JdbcH2Helper adds 582cfed refs #2892 Delegate methods from JdbcConfigurationBuilder to TopiaConfigurationBuilder adds 9d93f47 refs #2892 Fix TopiaConnectionProviderTest adds f7ee5db Configuration is now Serializable adds 5c6e6d8 Implements guessHibernateDialect adds d67aa11 Allow user to instantiate TopiaIdFactory adds 098f5b7 Enable connection pooling by default adds 85d6120 Make builders instantiables adds 8837683 fix dialect detection for H2 compatibility mode adds 4fe77ed log properties before starting hibernate provider adds a3a33ad Remove TopiaConfiguration.builder adds 15ceae1 Code review adds 504ac56 Merge branch 'feature/2892' into develop adds 841c333 Set default TopiaIdFactory to 'FullyQualifiedNamePlusUuidTopiaIdFactory' adds f2d8d57 refs #2892 Fix setTopiaIdFactory(...) only if necessary adds d50e212 refs #2892 Fix Ano-1640 IT adds 085a3e6 refs #2892 fix maven dependency issues adds cd25c6a refs #2892 Keep ToPIA Java 1.6 compatible adds c35d450 Fix missing file headers adds 1b14da6 Bullshit adds 61f31da Introduce TopiaConfiguration#isValidateSchema and implement it adds bfff0f4 fix wrong test on configuration properties generation adds 5938b9f Merge branch 'feature/3685' into develop (fixes #3685) adds 371011e Use pom 2.0 adds 92dfd24 Downgrade H2 to 1.3 to make the build stable adds 7e93f11 [jgitflow-maven-plugin]updating develop poms to master versions to avoid merge conflicts adds 19a59bb [jgitflow-maven-plugin]updating poms for 3.0-beta-17 branch with snapshot versions adds 89a3c59 Add missing file header adds 6e00dbc [jgitflow-maven-plugin]updating poms for branch'release/3.0-beta-17' with non-snapshot versions adds 5040793 [jgitflow-maven-plugin]merging 'release/3.0-beta-17' into 'master' adds 41d7248 [jgitflow-maven-plugin]merging 'master' into 'develop' adds e67123a [jgitflow-maven-plugin]Updating develop poms back to pre merge state new 26c869a For each entity of the model, generate a indexes.ddl file (refs #3452) new 928fa63 Improve (see #3674) and fix (see #3675) (when using dbName on reverse attribute) the name of generated index (refs #3452) This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (314c55b) \ N -- N -- N refs/heads/feature/3452 (928fa63) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omits" are not gone; other references still refer to them. Any revisions marked "discards" are gone forever. 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 928fa63835031ee9627e3bc29ccbb49ae304c1db Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Apr 22 12:44:06 2015 +0200 Improve (see #3674) and fix (see #3675) (when using dbName on reverse attribute) the name of generated index (refs #3452) commit 26c869a635dcb417bb6082592b1ae7025274d05b Author: Brendan Le Ny <bleny@codelutin.com> Date: Mon Feb 2 12:39:20 2015 +0100 For each entity of the model, generate a indexes.ddl file (refs #3452) Summary of changes: pom.xml | 14 +- topia-it/pom.xml | 5 - .../topia/testabstract/TopiaAbstractTest.java | 2 +- ...TopiaDatabase.java => TopiaIt1640Database.java} | 18 +- .../nuiton/topia/it/TopiaConfigurationHelper.java | 126 ------ .../org/nuiton/topia/it/TopiaSchemaHelper.java | 109 ------ .../AbstractTopiaItLegacyApplicationContext.java | 5 + .../TopiaItMappingTopiaApplicationContext.java | 56 +++ .../src/main/resources/TopiaContextImpl.properties | 39 -- .../nuiton/topia/it/legacy/AbstractLegacyTest.java | 2 - .../org/nuiton/topia/it/legacy/TestHelper.java | 173 --------- .../legacy/TopiaApplicationContextCacheTest.java | 206 ---------- .../topia/it/legacy/TopiaItLegacyDatabase.java | 23 +- .../topia/it/legacy/TopiaJpaSupportTest.java | 11 +- .../it/legacy/evo3396/FetchPropertiesTest.java | 17 +- .../TopiaConnectionProviderHardCoded.java | 30 +- .../framework/TopiaConnectionProviderTest.java | 99 +++-- .../framework/TopiaContextReplicateTest.java | 30 +- .../topia/it/legacy/framework/TopiaUtilTest.java | 27 +- .../topia/it/legacy/generator/TopiaTestCase.java | 4 +- .../persistence/EntityVisitorExportXmlTest.java | 4 +- .../topia/it/legacy/persistence/NaturalIdTest.java | 10 +- .../persistence/util/TopiaEntityHelperTest.java | 4 +- .../test/ano1882/DAOAbstractTransformerTest.java | 2 +- .../topia/it/legacy/topiatest/CascadeSaveTest.java | 2 +- .../nuiton/topia/it/legacy/topiatest/EnumTest.java | 4 +- .../topiatest/deletetest/DeleteEntityTest.java | 6 +- .../topia/it/mapping/AbstractMappingTest.java | 13 +- .../topia/it/mapping/TopiaItMappingDatabase.java | 101 ----- .../test1/BiDirectionalOneToManyRelationTest.java | 2 +- ...ectionalOneToManyRelationWithRoleNamedTest.java | 2 +- .../mapping/test1/SimpleOneToManyRelationTest.java | 2 +- .../SimpleOneToManyRelationWithRoleNamedTest.java | 2 +- .../test11/EntityWithBasicUniqueFieldsTest.java | 2 +- .../mapping/test11/SimpleManyToManyUniqueTest.java | 2 +- .../SimpleManyToManyWithRoleNamedUniqueTest.java | 2 +- .../mapping/test11/SimpleOneToManyUniqueTest.java | 2 +- .../SimpleOneToManyWithRoleNamedUniqueTest.java | 2 +- .../test12/EntityWithBasicNotNullFieldsTest.java | 2 +- .../it/mapping/test13/EntityWithNaturalIdTest.java | 2 +- .../mapping/test14/BidiAssociationClassTest.java | 2 +- .../test14/ManyToManyAssociationClassTest.java | 2 +- .../test14/OneToManyAssociationClassTest.java | 2 +- .../topia/it/mapping/test17/FixAno2342Test.java | 2 +- .../topia/it/mapping/test17/FixAno3280Test.java | 18 +- .../test2/BiDirectionalManyToOneRelationTest.java | 2 +- ...ectionalManyToOneRelationWithRoleNamedTest.java | 2 +- .../mapping/test2/SimpleManyToOneRelationTest.java | 2 +- .../SimpleManyToOneRelationWithRoleNamedTest.java | 2 +- .../test3/BiDirectionalManyToManyRelationTest.java | 2 +- ...ctionalManyToManyRelationWithRoleNamedTest.java | 2 +- .../test3/SimpleManyToManyRelationTest.java | 2 +- .../SimpleManyToManyRelationWithRoleNamedTest.java | 2 +- .../it/mapping/test4/ElementCollectionTest.java | 2 +- .../BiDirectionalOneToManyCompositionTest.java | 2 +- .../it/mapping/test5/OneToManyCompositionTest.java | 2 +- .../mapping/test6/SimpleOneToManyIndexedTest.java | 2 +- .../SimpleOneToManyWithRoleNamedIndexedTest.java | 2 +- .../mapping/test7/SimpleOneToManyOrderByTest.java | 2 +- .../mapping/test7/SimpleOneToManyOrderedTest.java | 2 +- .../persistence/internal/EntityListenerTest.java | 14 +- .../topia/persistence/internal/TopiaDaoTest.java | 2 +- .../persistence/internal/TopiaIdFactoryTest.java | 2 +- .../internal/TopiaSchemaCreationTest.java | 251 ------------ .../TopiaConnectionProviderHardcoded.properties | 34 -- topia-junit/pom.xml | 24 -- .../topia/junit/AbstractDatabaseResource.java | 119 +----- .../nuiton/topia/junit/ConfigurationHelper.java | 93 ----- topia-persistence/pom.xml | 10 + .../topia/persistence/BeanTopiaConfiguration.java | 162 ++++++++ ...nation.java => HibernateAvailableSettings.java} | 27 +- .../HibernateTopiaMigrationService.java} | 34 +- .../SchemaValidationTopiaException.java | 71 ++++ .../topia/persistence/TopiaApplicationContext.java | 5 +- .../persistence/TopiaApplicationContextCache.java | 15 +- .../topia/persistence/TopiaConfiguration.java | 88 +++++ .../persistence/TopiaConfigurationBuilder.java | 428 +++++++++++++++++++++ .../persistence/TopiaConfigurationConstants.java | 114 ++++-- .../nuiton/topia/persistence/TopiaIdFactory.java | 11 +- ...on.java => TopiaMisconfigurationException.java} | 27 +- .../org/nuiton/topia/persistence/TopiaService.java | 7 - .../internal/AbstractTopiaApplicationContext.java | 153 +++----- ...opiaPersistenceContextConstructorParameter.java | 22 ++ .../internal/DefaultTopiaIdFactory.java | 90 +---- ... FullyQualifiedNamePlusUuidTopiaIdFactory.java} | 9 +- .../persistence/internal/HibernateProvider.java | 246 ++++++------ .../persistence/internal/LegacyTopiaIdFactory.java | 2 + .../persistence/internal/ShortTopiaIdFactory.java | 23 +- .../internal/TopiaConnectionProvider.java | 15 +- .../internal/support/TopiaServiceSupportImpl.java | 99 ++--- .../persistence/jdbc/BeanJdbcConfiguration.java | 73 ++++ .../JdbcConfiguration.java} | 48 +-- .../persistence/jdbc/JdbcConfigurationBuilder.java | 261 +++++++++++++ .../topia/persistence/jdbc/JdbcH2Helper.java | 119 ++++++ .../nuiton/topia/persistence/jdbc/JdbcHelper.java | 166 ++++++++ .../nuiton/topia/persistence/util/TopiaH2Util.java | 10 +- .../nuiton/topia/persistence/util/TopiaUtil.java | 54 +-- ...lyQualifiedNamePlusUuidTopiaIdFactoryTest.java} | 10 +- .../persistence/TopiaConfigurationBuilderTest.java | 108 ++++++ .../internal/support/MyFirstTopiaServiceImpl.java | 5 - .../internal/support/MySecondTopiaServiceImpl.java | 5 - .../support/TopiaServiceSupportImplTest.java | 91 ----- .../topia/flyway/TopiaFlywayServiceImpl.java | 17 +- .../TopiaServiceFlywayInitOnCreateSchemaTest.java | 171 +++----- .../src/test/resources/log4j.properties | 2 +- .../topia/liquibase/TopiaLiquibaseServiceImpl.java | 15 +- .../topia/migration/TopiaMigrationEngine.java | 35 +- .../topia/migration/TopiaMigrationService.java | 2 +- .../topia/migration/TopiaMigrationEngineTest.java | 233 +++-------- .../replication/TopiaReplicationServiceImpl.java | 6 - .../AbstractTopiaReplicationServiceTest.java | 16 +- .../replication/TopiaReplicationOperationTest.java | 52 +-- .../TopiaReplicationServiceImplAllTest.java | 57 +-- .../TopiaReplicationServiceImplTest.java | 59 +-- .../templates/ApplicationContextTransformer.java | 15 +- .../topia/templates/EntityEnumTransformer.java | 32 +- 116 files changed, 2414 insertions(+), 2665 deletions(-) rename topia-it/src/it/ANOMALIE-1640/src/test/java/org/nuiton/topia/testabstract/{TopiaDatabase.java => TopiaIt1640Database.java} (64%) delete mode 100644 topia-it/src/main/java/org/nuiton/topia/it/TopiaConfigurationHelper.java delete mode 100644 topia-it/src/main/java/org/nuiton/topia/it/TopiaSchemaHelper.java create mode 100644 topia-it/src/main/java/org/nuiton/topia/it/mapping/TopiaItMappingTopiaApplicationContext.java delete mode 100644 topia-it/src/main/resources/TopiaContextImpl.properties delete mode 100644 topia-it/src/test/java/org/nuiton/topia/it/legacy/TestHelper.java delete mode 100644 topia-it/src/test/java/org/nuiton/topia/it/legacy/TopiaApplicationContextCacheTest.java delete mode 100644 topia-it/src/test/java/org/nuiton/topia/it/mapping/TopiaItMappingDatabase.java delete mode 100644 topia-it/src/test/java/org/nuiton/topia/persistence/internal/TopiaSchemaCreationTest.java delete mode 100644 topia-it/src/test/resources/TopiaConnectionProviderHardcoded.properties delete mode 100644 topia-junit/src/main/java/org/nuiton/topia/junit/ConfigurationHelper.java create mode 100644 topia-persistence/src/main/java/org/nuiton/topia/persistence/BeanTopiaConfiguration.java copy topia-persistence/src/main/java/org/nuiton/topia/persistence/{TopiaReplicationDestination.java => HibernateAvailableSettings.java} (58%) copy topia-persistence/src/{test/java/org/nuiton/topia/persistence/internal/support/MySecondTopiaServiceImpl.java => main/java/org/nuiton/topia/persistence/HibernateTopiaMigrationService.java} (60%) create mode 100644 topia-persistence/src/main/java/org/nuiton/topia/persistence/SchemaValidationTopiaException.java create mode 100644 topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaConfiguration.java create mode 100644 topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaConfigurationBuilder.java copy topia-persistence/src/main/java/org/nuiton/topia/persistence/{TopiaMigrationServiceException.java => TopiaMisconfigurationException.java} (56%) copy topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/{DefaultTopiaIdFactory.java => FullyQualifiedNamePlusUuidTopiaIdFactory.java} (93%) create mode 100644 topia-persistence/src/main/java/org/nuiton/topia/persistence/jdbc/BeanJdbcConfiguration.java copy topia-persistence/src/main/java/org/nuiton/topia/persistence/{support/TopiaHibernateSupport.java => jdbc/JdbcConfiguration.java} (54%) create mode 100644 topia-persistence/src/main/java/org/nuiton/topia/persistence/jdbc/JdbcConfigurationBuilder.java create mode 100644 topia-persistence/src/main/java/org/nuiton/topia/persistence/jdbc/JdbcH2Helper.java create mode 100644 topia-persistence/src/main/java/org/nuiton/topia/persistence/jdbc/JdbcHelper.java rename topia-persistence/src/test/java/org/nuiton/topia/persistence/{DefaultTopiaIdFactoryTest.java => FullyQualifiedNamePlusUuidTopiaIdFactoryTest.java} (90%) create mode 100644 topia-persistence/src/test/java/org/nuiton/topia/persistence/TopiaConfigurationBuilderTest.java delete mode 100644 topia-persistence/src/test/java/org/nuiton/topia/persistence/internal/support/TopiaServiceSupportImplTest.java -- 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 feature/3452 in repository topia. See http://git.nuiton.org/topia.git commit 26c869a635dcb417bb6082592b1ae7025274d05b Author: Brendan Le Ny <bleny@codelutin.com> Date: Mon Feb 2 12:39:20 2015 +0100 For each entity of the model, generate a indexes.ddl file (refs #3452) --- .../topia/templates/IndexesDdlGenerator.java | 126 +++++++++++++++++++++ .../topia/templates/TopiaMetaTransformer.java | 3 +- 2 files changed, 128 insertions(+), 1 deletion(-) diff --git a/topia-templates/src/main/java/org/nuiton/topia/templates/IndexesDdlGenerator.java b/topia-templates/src/main/java/org/nuiton/topia/templates/IndexesDdlGenerator.java new file mode 100644 index 0000000..17e2289 --- /dev/null +++ b/topia-templates/src/main/java/org/nuiton/topia/templates/IndexesDdlGenerator.java @@ -0,0 +1,126 @@ +package org.nuiton.topia.templates; + +/* + * #%L + * ToPIA :: Templates + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2014 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +import org.apache.commons.lang3.StringUtils; +import org.nuiton.eugene.GeneratorUtil; +import org.nuiton.eugene.models.object.ObjectModelAttribute; +import org.nuiton.eugene.models.object.ObjectModelClass; +import org.nuiton.eugene.models.object.ObjectModelGenerator; +import org.nuiton.eugene.models.object.ObjectModelPackage; + +import java.io.File; +import java.io.IOException; +import java.io.Writer; + +/*{generator option: parentheses = true}*/ +/*{generator option: writeString = output.write}*/ + +/** + * Generate files with CREATE INDEX statements + * + * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.topia.templates.IndexesDdlGenerator" + */ +public class IndexesDdlGenerator extends ObjectModelGenerator { + + protected TopiaTemplateHelper templateHelper; + + protected TopiaTagValues topiaTagValues; + + @Override + public String getFilenameForClass(ObjectModelClass clazz) { + if (templateHelper == null) { + templateHelper = new TopiaTemplateHelper(model); + } + return clazz.getQualifiedName().replace('.', File.separatorChar) + "-indexes.ddl"; + } + + @Override + public void generateFromClass(Writer output, + ObjectModelClass input) throws IOException { + + if (templateHelper == null) { + templateHelper = new TopiaTemplateHelper(model); + } + if (topiaTagValues == null) { + topiaTagValues = templateHelper.getTopiaTagValues(); + } + + for (ObjectModelAttribute attribute : input.getAttributes()) { + if (!attribute.isNavigable() || + attribute.hasAssociationClass() || + !GeneratorUtil.isNMultiplicity(attribute) || + attribute.getClassifier() == null || + !templateHelper.isEntity(attribute.getClassifier()) || + templateHelper.isAbstract(attribute.getClassifier()) + ) { + + // skip for this case (not a nm-multiplicity attribute) + continue; + } + + ObjectModelPackage aPackage = model.getPackage(input); + + boolean indexForeignKeys = + topiaTagValues.getIndexForeignKeysTagValue(attribute, aPackage, model); + + if (!indexForeignKeys) { + + // no index to put of the attribute. + continue; + } + + // add database-object to create and drop index + + String tableName; + String indexName = "idx_" + input.getName() + "_" + attribute.getName(); + String propertyName; + + + if (GeneratorUtil.isNMultiplicity(attribute.getReverseMaxMultiplicity())) { + + // many to many + tableName = templateHelper.getManyToManyTableName(attribute); + propertyName = templateHelper.getDbName(attribute.getReverseAttribute()); + } else { + + // one to many + tableName =templateHelper.getDbName(attribute.getClassifier()); + propertyName = templateHelper.getDbName(attribute.getReverseAttribute()); + } + + // add schema if exist (http://nuiton.org/issues/2052) + String schema = topiaTagValues.getDbSchemaNameTagValue(input, model); + if (StringUtils.isNotEmpty(schema)) { + tableName = schema + "." + tableName; + } +/*{ +CREATE INDEX <%=indexName%> ON <%=tableName%>(<%=propertyName%>); +}*/ + + } + } + +} diff --git a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaMetaTransformer.java b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaMetaTransformer.java index 4da8fcd..9e4ac16 100644 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaMetaTransformer.java +++ b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaMetaTransformer.java @@ -69,7 +69,8 @@ public class TopiaMetaTransformer extends AbstractMetaTransformer<ObjectModel> { EntityDaoTransformer.class, EntityEnumTransformer.class, ApplicationContextTransformer.class, - PersistenceContextTransformer.class + PersistenceContextTransformer.class, + IndexesDdlGenerator.class ); } -- 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 feature/3452 in repository topia. See http://git.nuiton.org/topia.git commit 928fa63835031ee9627e3bc29ccbb49ae304c1db Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Apr 22 12:44:06 2015 +0200 Improve (see #3674) and fix (see #3675) (when using dbName on reverse attribute) the name of generated index (refs #3452) --- .../templates/EntityHibernateMappingGenerator.java | 17 ++++++--- .../topia/templates/IndexesDdlGenerator.java | 21 +++++++---- .../topia/templates/TopiaTemplateHelper.java | 42 ++++++++++++++++++++++ 3 files changed, 68 insertions(+), 12 deletions(-) diff --git a/topia-templates/src/main/java/org/nuiton/topia/templates/EntityHibernateMappingGenerator.java b/topia-templates/src/main/java/org/nuiton/topia/templates/EntityHibernateMappingGenerator.java index 573f270..eff80cb 100644 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/EntityHibernateMappingGenerator.java +++ b/topia-templates/src/main/java/org/nuiton/topia/templates/EntityHibernateMappingGenerator.java @@ -269,25 +269,32 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { // add database-object to create and drop index String tableName; - String indexName = "idx_" + clazz.getName() + "_" + attribute.getName(); String propertyName; - if (GeneratorUtil.isNMultiplicity(attribute.getReverseMaxMultiplicity())) { // many to many tableName = templateHelper.getManyToManyTableName(attribute); - propertyName = templateHelper.getDbName(attribute.getReverseAttribute()); + propertyName = templateHelper.getReverseDbNameOnReverseAttribute(attribute); } else { // one to many tableName =templateHelper.getDbName(attribute.getClassifier()); - propertyName = templateHelper.getDbName(attribute.getReverseAttribute()); + propertyName = templateHelper.getReverseDbNameOnReverseAttribute(attribute); } // add schema if exist (http://nuiton.org/issues/2052) String schema = topiaTagValues.getDbSchemaNameTagValue(clazz, model); - if (StringUtils.isNotEmpty(schema)) { + boolean withSchema = StringUtils.isNotEmpty(schema); + + String indexName = "idx"; + if (withSchema) { + indexName += '_' + schema; + } + indexName += '_' + tableName+ '_' + propertyName ; + indexName = indexName.toLowerCase(); + + if (withSchema) { tableName = schema + "." + tableName; } /*{ <database-object> diff --git a/topia-templates/src/main/java/org/nuiton/topia/templates/IndexesDdlGenerator.java b/topia-templates/src/main/java/org/nuiton/topia/templates/IndexesDdlGenerator.java index 17e2289..97a0370 100644 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/IndexesDdlGenerator.java +++ b/topia-templates/src/main/java/org/nuiton/topia/templates/IndexesDdlGenerator.java @@ -68,6 +68,8 @@ public class IndexesDdlGenerator extends ObjectModelGenerator { topiaTagValues = templateHelper.getTopiaTagValues(); } + ObjectModelPackage aPackage = model.getPackage(input); + for (ObjectModelAttribute attribute : input.getAttributes()) { if (!attribute.isNavigable() || attribute.hasAssociationClass() || @@ -81,8 +83,6 @@ public class IndexesDdlGenerator extends ObjectModelGenerator { continue; } - ObjectModelPackage aPackage = model.getPackage(input); - boolean indexForeignKeys = topiaTagValues.getIndexForeignKeysTagValue(attribute, aPackage, model); @@ -95,25 +95,32 @@ public class IndexesDdlGenerator extends ObjectModelGenerator { // add database-object to create and drop index String tableName; - String indexName = "idx_" + input.getName() + "_" + attribute.getName(); String propertyName; - if (GeneratorUtil.isNMultiplicity(attribute.getReverseMaxMultiplicity())) { // many to many tableName = templateHelper.getManyToManyTableName(attribute); - propertyName = templateHelper.getDbName(attribute.getReverseAttribute()); + propertyName = templateHelper.getReverseDbNameOnReverseAttribute(attribute); } else { // one to many tableName =templateHelper.getDbName(attribute.getClassifier()); - propertyName = templateHelper.getDbName(attribute.getReverseAttribute()); + propertyName = templateHelper.getReverseDbNameOnReverseAttribute(attribute); } // add schema if exist (http://nuiton.org/issues/2052) String schema = topiaTagValues.getDbSchemaNameTagValue(input, model); - if (StringUtils.isNotEmpty(schema)) { + boolean withSchema = StringUtils.isNotEmpty(schema); + + String indexName = "idx"; + if (withSchema) { + indexName += '_' + schema; + } + indexName += '_' + tableName+ '_' + propertyName ; + indexName = indexName.toLowerCase(); + + if (withSchema) { tableName = schema + "." + tableName; } /*{ diff --git a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTemplateHelper.java b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTemplateHelper.java index 1d0020d..38e7fd6 100644 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTemplateHelper.java +++ b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTemplateHelper.java @@ -266,6 +266,48 @@ public class TopiaTemplateHelper { } /** + * Obtain the reverse db name of a reverse attribute. + * + * <strong>Note that the reverse attribute can't be null here.</strong> + * <ul> + * <li>Try first to get the reverse db Name from the ReverseDbname tag-value</li> + * <li>If not found, try then the ReverseDbname tag-value on the same attribute but from this other side of the relation</li> + * <li>If not found, try then just get the name of the reverse attribute name</li> + * </ul> + * @param attr the attribute to seek + * @return the value of the reverse db name on the revser attribute + * @since 2.9.5.2 + * @deprecated Eugene should deal with this + */ + @Deprecated + public String getReverseDbNameOnReverseAttribute(ObjectModelAttribute attr) { + + ObjectModelAttribute reverseAttribute = attr.getReverseAttribute(); + + if (reverseAttribute == null) { + throw new IllegalArgumentException("The reverse attribute can't be null, but was on " + attr); + } + + String result = topiaTagValues.findDirectTagValue(TopiaTagValues.TAG_REVERSE_DB_NAME, reverseAttribute); + if (StringUtils.isEmpty(result)) { + + // Try to get it from the other site of the relation + ObjectModelAttribute reverseAttribute2 = reverseAttribute.getClassifier().getAttribute(attr.getName()); + result = topiaTagValues.findDirectTagValue(TopiaTagValues.TAG_REVERSE_DB_NAME, reverseAttribute2); + + } + + if (StringUtils.isEmpty(result)) { + + result = GeneratorUtil.toLowerCaseFirstLetter(reverseAttribute.getName()); + + } + + return result; + + } + + /** * Renvoie le nom BD de l'élement passé en paramètre. Elle se base sur le * tag associé si il existe, sinon sur le nom de l'élément * -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm