branch feature/4062 updated (81c24a2 -> 31790ef)
This is an automated email from the git hooks/post-receive script. New change to branch feature/4062 in repository topia. See https://gitlab.nuiton.org/nuiton/topia.git omits 81c24a2 optimize third parties omits 5b17427 Optimize dependencies omits b98cde5 Hibernate 5 requires java 8 omits 43573ae Add persistent classes to configuration (otherwise sessionFactory do not know them) + review newSessionFactory method omits 173df4f Fix dao detection omits 8abfa83 Fix tests by preventing validation while testing TopiaUtil omits 0693425 Update to hibernate 5.2.3 adds 309b6ae When migration fails, must throw an exception (Fixes #4080) adds 42e62ea Remove deprecated usage of guava Iterators.emptyIterator() (Fixes #4082) adds e7e0b6e Updates to guava 20 (Fixes #4083) adds d9a3acc Updates liquidbase to 3.5.3 (Fixes #4084) adds b641091 Updates flyway to 4.0.3 (Fixes #4085) adds 477f3c0 Updates beanutils to 1.9.3 (Fixes #4086) adds fc409d9 Updates commons-lang3 to 3.5 (Fixes #4087) adds b7db629 Updates mockito to 2.2.29 (Fixes #4088) adds aaa694c Updates nuiton-csv to 3.0-rc-6 (Fixes #4089) adds 923aa40 Updates nuiton-utils to 3.0-rc-16 (Fixes #4090) adds fdb8c5b Updates eugene to 3.0-alpha-10 (Fixes #4091) adds d161b0e We should also propagate hibernate extra configuration to the TMSconfiguration (fixes #4092) adds e9dcf56 [jgitflow-maven-plugin]updating develop poms to master versions to avoid merge conflicts adds 1056d05 [jgitflow-maven-plugin]updating poms for 3.1.4 branch with snapshot versions adds 04e5299 [jgitflow-maven-plugin]updating poms for branch'release/3.1.4' with non-snapshot versions adds 97dd087 [jgitflow-maven-plugin]merging 'release/3.1.4' into 'master' adds e5be5e3 [jgitflow-maven-plugin]merging 'master' into 'develop' adds 54dfd7b [jgitflow-maven-plugin]Updating develop poms back to pre merge state adds 357137b Bad generation of delete method in generated dao for *-* relation if surrounding entity is not in the same schema (fixes #4096) new 42ca064 Update to hibernate 5.2.3 new 1e1f0dc Fix tests by preventing validation while testing TopiaUtil new 4985b2d Fix dao detection new dccf8d7 Add persistent classes to configuration (otherwise sessionFactory do not know them) + review newSessionFactory method new a6d3be2 Hibernate 5 requires java 8 new 061b98f Optimize dependencies new a3f2395 optimize third parties new 763e62b refs #4062 Go back to hibernate 5.1.3 to stay on java 7 new d71c50a refs #4062 Fix the shcema validation exception hack :( new 31790ef refs #4062 Fix two tests 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 (81c24a2) \ N -- N -- N refs/heads/feature/4062 (31790ef) 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 10 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 31790ef2c9eedc5e8ecdb45687022cc77451ca72 Author: Tony CHEMIT <chemit@codelutin.com> Date: Thu Dec 15 11:32:49 2016 +0100 refs #4062 Fix two tests commit d71c50ac63e3d2fe7aaa085bf190a72fda796afc Author: Tony CHEMIT <chemit@codelutin.com> Date: Thu Dec 15 11:32:32 2016 +0100 refs #4062 Fix the shcema validation exception hack :( commit 763e62bf270dcde1f3efecc231504bdf8a231b4f Author: Tony CHEMIT <chemit@codelutin.com> Date: Thu Dec 15 11:31:52 2016 +0100 refs #4062 Go back to hibernate 5.1.3 to stay on java 7 commit a3f23951a314caa402868d2e876f0b1d629723f5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Oct 23 16:21:51 2016 +0200 optimize third parties commit 061b98f70e2fd0badb40c0cb7f16a34c8f8532c6 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Oct 23 16:21:33 2016 +0200 Optimize dependencies commit a6d3be272839c7d8ddcf303b1c0a1b55735a29fa Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Oct 23 15:59:34 2016 +0200 Hibernate 5 requires java 8 commit dccf8d731f38a65fc8c4b4e0ebdfbdb2e62c4bc2 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Oct 23 11:18:35 2016 +0200 Add persistent classes to configuration (otherwise sessionFactory do not know them) + review newSessionFactory method commit 4985b2dfc9bce5ff43f284b05105791c65906fa8 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Oct 23 11:16:37 2016 +0200 Fix dao detection commit 1e1f0dcb65093a483c350c6c8d3dcd1ae3cb0cac Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Oct 18 17:23:09 2016 +0200 Fix tests by preventing validation while testing TopiaUtil commit 42ca0647f7e7e10ddcba52b53fcc0d5de5064c3a Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Oct 8 10:20:02 2016 +0200 Update to hibernate 5.2.3 Summary of changes: pom.xml | 24 +++++----- .../topia/it/legacy/persistence/NaturalIdTest.java | 7 ++- .../SchemaValidationTopiaException.java | 9 ++-- .../persistence/internal/AbstractTopiaDao.java | 3 +- .../internal/AbstractTopiaPersistenceContext.java | 51 +++++++++++----------- .../nuiton/topia/persistence/util/TopiaUtil.java | 21 ++++----- .../topia/flyway/TopiaFlywayServiceImpl.java | 7 +-- .../migration/AbstractTopiaMigrationCallback.java | 12 +++-- .../topia/migration/TopiaMigrationEngine.java | 1 + .../topia/migration/TopiaMigrationEngineTest.java | 2 +- .../topia/templates/EntityDaoTransformer.java | 10 ++--- 11 files changed, 73 insertions(+), 74 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 feature/4062 in repository topia. See https://gitlab.nuiton.org/nuiton/topia.git commit 42ca0647f7e7e10ddcba52b53fcc0d5de5064c3a Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Oct 8 10:20:02 2016 +0200 Update to hibernate 5.2.3 --- pom.xml | 2 +- .../topia/it/legacy/framework/TopiaUtilTest.java | 9 +- .../topia/it/legacy/persistence/NaturalIdTest.java | 5 +- .../internal/AbstractTopiaApplicationContext.java | 71 ++++----- .../internal/AbstractTopiaPersistenceContext.java | 38 ++++- .../persistence/internal/HibernateProvider.java | 64 +++++++- .../persistence/support/TopiaHibernateSupport.java | 6 + .../nuiton/topia/persistence/util/TopiaUtil.java | 177 ++++++++------------- .../topia/migration/TopiaMigrationEngine.java | 22 +-- .../migration/mappings/TMSVersionHibernateDao.java | 23 ++- 10 files changed, 235 insertions(+), 182 deletions(-) diff --git a/pom.xml b/pom.xml index 719d728..a373e8f 100644 --- a/pom.xml +++ b/pom.xml @@ -225,7 +225,7 @@ <h2Version>1.3.176</h2Version> <hamcrestVersion>1.3</hamcrestVersion> - <hibernateVersion>4.3.11.Final</hibernateVersion> + <hibernateVersion>5.2.3.Final</hibernateVersion> <javassistVersion>3.20.0-GA</javassistVersion> <junitVersion>4.12</junitVersion> <liquibaseVersion>3.5.3</liquibaseVersion> diff --git a/topia-it/src/test/java/org/nuiton/topia/it/legacy/framework/TopiaUtilTest.java b/topia-it/src/test/java/org/nuiton/topia/it/legacy/framework/TopiaUtilTest.java index be1d8db..d095150 100644 --- a/topia-it/src/test/java/org/nuiton/topia/it/legacy/framework/TopiaUtilTest.java +++ b/topia-it/src/test/java/org/nuiton/topia/it/legacy/framework/TopiaUtilTest.java @@ -24,6 +24,7 @@ package org.nuiton.topia.it.legacy.framework; * #L% */ +import org.hibernate.boot.Metadata; import org.hibernate.cfg.Configuration; import org.junit.Rule; import org.junit.Test; @@ -101,7 +102,8 @@ public class TopiaUtilTest { @Test(expected = IllegalArgumentException.class) public void testIsSchemaExistFailed() throws Exception { Configuration hibernateCfg = db.getApplicationContext().getHibernateProvider().getHibernateConfiguration(); - TopiaUtil.isSchemaExist(hibernateCfg, "fake"); + Metadata metaData = db.getApplicationContext().getHibernateProvider().getMetaData(); + TopiaUtil.isSchemaExist(hibernateCfg,metaData, "fake"); } @Test @@ -109,14 +111,15 @@ public class TopiaUtilTest { String personClassName = PersonImpl.class.getName(); Configuration hibernateCfg = db.getApplicationContext().getHibernateProvider().getHibernateConfiguration(); + Metadata metaData = db.getApplicationContext().getHibernateProvider().getMetaData(); // First, test before DB is created, the table should not exist - assertFalse(TopiaUtil.isSchemaExist(hibernateCfg, personClassName)); + assertFalse(TopiaUtil.isSchemaExist(hibernateCfg,metaData, personClassName)); // Create schema db.getApplicationContext().createSchema(); // Now table should exist - assertTrue(TopiaUtil.isSchemaExist(hibernateCfg, personClassName)); + assertTrue(TopiaUtil.isSchemaExist(hibernateCfg, metaData, personClassName)); } } diff --git a/topia-it/src/test/java/org/nuiton/topia/it/legacy/persistence/NaturalIdTest.java b/topia-it/src/test/java/org/nuiton/topia/it/legacy/persistence/NaturalIdTest.java index e30192e..6a90910 100644 --- a/topia-it/src/test/java/org/nuiton/topia/it/legacy/persistence/NaturalIdTest.java +++ b/topia-it/src/test/java/org/nuiton/topia/it/legacy/persistence/NaturalIdTest.java @@ -37,6 +37,8 @@ import org.nuiton.topia.it.legacy.TopiaItLegacyTopiaPersistenceContext; import org.nuiton.topia.it.legacy.topiatest.NaturalizedEntity; import org.nuiton.topia.it.legacy.topiatest.NaturalizedEntityTopiaDao; +import javax.persistence.PersistenceException; + /** * NaturalIdTest * @@ -115,8 +117,7 @@ public class NaturalIdTest { entity.setNaturalIdNotNull(8); persistenceContext.commit(); } catch (TopiaException eee) { - Assert.assertEquals("org.hibernate.HibernateException", - eee.getCause().getClass().getName()); + Assert.assertEquals(PersistenceException.class, eee.getCause().getClass()); } } diff --git a/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/AbstractTopiaApplicationContext.java b/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/AbstractTopiaApplicationContext.java index e2d1346..66c2960 100644 --- a/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/AbstractTopiaApplicationContext.java +++ b/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/AbstractTopiaApplicationContext.java @@ -31,10 +31,13 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.HibernateException; +import org.hibernate.boot.Metadata; +import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; import org.hibernate.mapping.PersistentClass; import org.hibernate.tool.hbm2ddl.SchemaExport; import org.hibernate.tool.hbm2ddl.SchemaUpdate; +import org.hibernate.tool.schema.TargetType; import org.nuiton.topia.persistence.TopiaApplicationContext; import org.nuiton.topia.persistence.TopiaApplicationContextCache; import org.nuiton.topia.persistence.TopiaConfiguration; @@ -60,7 +63,7 @@ import java.beans.PropertyChangeListener; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Iterator; +import java.util.EnumSet; import java.util.List; import java.util.Map; import java.util.Properties; @@ -162,8 +165,8 @@ public abstract class AbstractTopiaApplicationContext<K extends TopiaPersistence * * This simple check is in its own method so it can be overridden. * - * @see org.nuiton.topia.persistence.TopiaConfiguration#isInitSchema() * @return FIXME + * @see org.nuiton.topia.persistence.TopiaConfiguration#isInitSchema() */ protected boolean isInitSchema() { boolean initSchema = configuration.isInitSchema(); @@ -359,8 +362,10 @@ public abstract class AbstractTopiaApplicationContext<K extends TopiaPersistence @Override public boolean isSchemaEmpty() { // AThimel 14/06/14 getHibernateConfiguration() may create the schema, prefer using newHibernateConfiguration() which doesn't - Configuration configuration = getHibernateProvider().getHibernateConfiguration(); - boolean result = TopiaUtil.isSchemaEmpty(configuration); + Configuration configuration = getHibernateProvider().newHibernateConfiguration(); + configuration.getProperties().put(AvailableSettings.HBM2DDL_AUTO, "none"); + Metadata metaData = getHibernateProvider().newMetaData(configuration); + boolean result = TopiaUtil.isSchemaEmpty(configuration, metaData); return result; } @@ -368,7 +373,8 @@ public abstract class AbstractTopiaApplicationContext<K extends TopiaPersistence public boolean isTableExists(Class<?> clazz) { // AThimel 14/06/14 getHibernateConfiguration() may create the schema, prefer using newHibernateConfiguration() which doesn't Configuration configuration = getHibernateProvider().getHibernateConfiguration(); - boolean result = TopiaUtil.isSchemaExist(configuration, clazz.getName()); + Metadata metaData = getHibernateProvider().getMetaData(); + boolean result = TopiaUtil.isSchemaExist(configuration, metaData, clazz.getName()); return result; } @@ -381,31 +387,27 @@ public abstract class AbstractTopiaApplicationContext<K extends TopiaPersistence @Override public void createSchema() { try { - boolean showSchema = false; + EnumSet<TargetType> targetTypes = EnumSet.of(TargetType.DATABASE); if (log.isDebugEnabled()) { - showSchema = true; + targetTypes.add(TargetType.STDOUT); } topiaFiresSupport.firePreCreateSchema(this); - Configuration hibernateConfiguration = getHibernateProvider().getHibernateConfiguration(); - new SchemaExport(hibernateConfiguration).execute(showSchema, true, false, true); + Configuration configuration = getHibernateProvider().newHibernateConfiguration(); + configuration.getProperties().remove(AvailableSettings.HBM2DDL_AUTO); + Metadata metadata = getHibernateProvider().newMetaData(configuration); + new SchemaExport().execute(targetTypes, SchemaExport.Action.CREATE, metadata); topiaFiresSupport.firePostCreateSchema(this); } catch (HibernateException eee) { - throw new TopiaException( - String.format("Could not create schema for reason: %s", - eee.getMessage()), eee); + throw new TopiaException(String.format("Could not create schema for reason: %s", eee.getMessage()), eee); } } @Override public void showCreateSchema() { try { - // AThimel 14/06/14 getHibernateConfiguration() may create the schema, prefer using newHibernateConfiguration() which doesn't - Configuration hibernateConfiguration = getHibernateProvider().getHibernateConfiguration(); - new SchemaExport(hibernateConfiguration).execute(true, false, false, true); + new SchemaExport().execute(EnumSet.of(TargetType.DATABASE, TargetType.STDOUT), SchemaExport.Action.CREATE, getHibernateProvider().getMetaData()); } catch (HibernateException eee) { - throw new TopiaException( - String.format("Could not show create schema for reason: %s", - eee.getMessage()), eee); + throw new TopiaException(String.format("Could not show create schema for reason: %s", eee.getMessage()), eee); } } @@ -413,40 +415,30 @@ public abstract class AbstractTopiaApplicationContext<K extends TopiaPersistence @Override public void updateSchema() { try { - boolean showSchema = false; + EnumSet<TargetType> targetTypes = EnumSet.of(TargetType.DATABASE); if (log.isDebugEnabled()) { - showSchema = true; + targetTypes.add(TargetType.STDOUT); } - topiaFiresSupport.firePreUpdateSchema(this); - // AThimel 14/06/14 getHibernateConfiguration() may create the schema, prefer using newHibernateConfiguration() which doesn't - Configuration hibernateConfiguration = getHibernateProvider().getHibernateConfiguration(); - new SchemaUpdate(hibernateConfiguration).execute(showSchema, true); + new SchemaUpdate().execute(targetTypes, getHibernateProvider().getMetaData()); topiaFiresSupport.firePostUpdateSchema(this); } catch (HibernateException eee) { - throw new TopiaException( - String.format("Could not update schema for reason: %s", - eee.getMessage()), eee); + throw new TopiaException(String.format("Could not update schema for reason: %s", eee.getMessage()), eee); } } @Override public void dropSchema() { try { - boolean showSchema = false; + EnumSet<TargetType> targetTypes = EnumSet.of(TargetType.DATABASE); if (log.isDebugEnabled()) { - showSchema = true; + targetTypes.add(TargetType.STDOUT); } - topiaFiresSupport.firePreDropSchema(this); - // AThimel 14/06/14 getHibernateConfiguration() may create the schema, prefer using newHibernateConfiguration() which doesn't - Configuration hibernateConfiguration = getHibernateProvider().getHibernateConfiguration(); - new SchemaExport(hibernateConfiguration).execute(showSchema, true, true, false); + new SchemaExport().execute(targetTypes, SchemaExport.Action.DROP, getHibernateProvider().getMetaData()); topiaFiresSupport.firePostDropSchema(this); } catch (HibernateException eee) { - throw new TopiaException( - String.format("Could not drop schema for reason: %s", - eee.getMessage()), eee); + throw new TopiaException(String.format("Could not drop schema for reason: %s", eee.getMessage()), eee); } } @@ -501,10 +493,9 @@ public abstract class AbstractTopiaApplicationContext<K extends TopiaPersistence @Override public ImmutableSet<String> getSchemaNames() { - ImmutableSet.Builder <String> result = ImmutableSet.builder(); - Iterator<PersistentClass> classMappings = hibernateProvider.getHibernateConfiguration().getClassMappings(); - while (classMappings.hasNext()) { - PersistentClass persistentClass = classMappings.next(); + ImmutableSet.Builder<String> result = ImmutableSet.builder(); + Collection<PersistentClass> classMappings = hibernateProvider.getMetaData().getEntityBindings(); + for (PersistentClass persistentClass : classMappings) { String schema = persistentClass.getIdentityTable().getSchema(); if (StringUtils.isNotEmpty(schema)) { result.add(schema); diff --git a/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/AbstractTopiaPersistenceContext.java b/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/AbstractTopiaPersistenceContext.java index 9124dd8..fb944dd 100644 --- a/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/AbstractTopiaPersistenceContext.java +++ b/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/AbstractTopiaPersistenceContext.java @@ -33,6 +33,7 @@ import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; +import org.hibernate.boot.Metadata; import org.hibernate.cfg.Configuration; import org.nuiton.topia.persistence.TopiaDao; import org.nuiton.topia.persistence.TopiaEntity; @@ -177,6 +178,11 @@ public abstract class AbstractTopiaPersistenceContext implements TopiaPersistenc } @Override + public Metadata getHibernateMetadata() { + return hibernateProvider.getMetaData(); + } + + @Override public Configuration getHibernateConfiguration() { return hibernateProvider.getHibernateConfiguration(); } @@ -272,13 +278,37 @@ public abstract class AbstractTopiaPersistenceContext implements TopiaPersistenc SessionFactory hibernateFactory = hibernateSupport.getHibernateFactory(); Preconditions.checkState(hibernateFactory != null, "The Hibernate SessionFactory is null, please initialize"); - if (hibernateFactory.getClassMetadata(entityClass) == null && - hibernateFactory.getClassMetadata(entityClass.getName() + "Impl") == null && - hibernateFactory.getClassMetadata(entityClass.getName() + "Abstract") == null) { + + boolean found = false; + try { + hibernateFactory.getMetamodel().entity(entityClass); + found = true; + } catch (Exception e) { + } + if (!found) { + try { + hibernateFactory.getMetamodel().entity(entityClass.getName() + "Impl"); + found = true; + } catch (Exception e) { + } + } + if (!found) { + try { + hibernateFactory.getMetamodel().entity(entityClass.getName() + "Abstract"); + found = true; + } catch (Exception e) { + } + } + +// if (hibernateFactory.getMetamodel().entity(entityClass) == null && +// hibernateFactory.getMetamodel().entity(entityClass.getName() + "Impl") == null && +// hibernateFactory.getMetamodel().entity(entityClass.getName() + "Abstract") == null) + + if (! found) { if (log.isInfoEnabled()) { String format = "List of supported persistence classes: %s"; - String message = String.format(format, hibernateFactory.getAllClassMetadata().keySet()); + String message = String.format(format, hibernateFactory.getMetamodel().getEntities()); log.info(message); } String format = "The following entity type %s is not managed by this context, you probably forgot to declare it."; diff --git a/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/HibernateProvider.java b/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/HibernateProvider.java index b875769..faf2574 100644 --- a/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/HibernateProvider.java +++ b/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/HibernateProvider.java @@ -28,7 +28,11 @@ import com.google.common.base.Preconditions; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.SessionFactory; +import org.hibernate.boot.Metadata; +import org.hibernate.boot.MetadataBuilder; +import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistry; +import org.hibernate.boot.spi.SessionFactoryOptions; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; import org.hibernate.dialect.DB2Dialect; @@ -56,6 +60,7 @@ import org.nuiton.topia.persistence.jdbc.JdbcConfigurationBuilder; import org.nuiton.topia.persistence.support.TopiaServiceSupport; import org.nuiton.topia.persistence.util.TopiaUtil; +import java.util.Collection; import java.util.Properties; import java.util.Set; @@ -75,12 +80,13 @@ public class HibernateProvider { protected TopiaServiceSupport topiaServiceSupport; protected TopiaHibernateSessionRegistry sessionRegistry; - /** * List of persistent classes */ protected Set<Class<? extends TopiaEntity>> entityClasses; + protected Metadata metaData; + public HibernateProvider(TopiaConfiguration topiaConfiguration, TopiaServiceSupport topiaServiceSupport, TopiaHibernateSessionRegistry sessionRegistry, @@ -102,9 +108,6 @@ public class HibernateProvider { hibernateConfiguration = newHibernateConfiguration(); TopiaUtil.warnOnAutomaticSchemaOperationRisk(hibernateConfiguration); - - // tchemit 2011-05-26 When using hibernate > 3.3, need to make sure all mappings are loaded (the one from directory files are not still done). - hibernateConfiguration.buildMappings(); } return hibernateConfiguration; } @@ -167,6 +170,7 @@ public class HibernateProvider { * * Prefer user defined dialect over dialect guessed by ToPIA; * Warn user if dialect declared seems wrong (H2 dialect for a PostgreSQL database) + * * @throws TopiaMisconfigurationException if user must add dialect to its configuration (because it can not be guessed) */ public static String getHibernateDialect(TopiaConfiguration topiaConfiguration) { @@ -274,10 +278,10 @@ public class HibernateProvider { * @param sessionFactory the Hibernate's SessionFactory instance * @return the StandardServiceRegistry instance used by the given SessionFactory */ - protected static StandardServiceRegistry getStandardServiceRegistry(SessionFactory sessionFactory) { + public static StandardServiceRegistry getStandardServiceRegistry(SessionFactory sessionFactory) { // AThimel 03/04/14 The next two lines are the good way to get the StandardServiceRegistry in Hibernate 4.3 - SessionFactory.SessionFactoryOptions sessionFactoryOptions = sessionFactory.getSessionFactoryOptions(); + SessionFactoryOptions sessionFactoryOptions = sessionFactory.getSessionFactoryOptions(); StandardServiceRegistry result = sessionFactoryOptions.getServiceRegistry(); return result; @@ -327,6 +331,7 @@ public class HibernateProvider { } public void close() { + metaData = null; if (hibernateSessionFactory != null) { Preconditions.checkState(!hibernateSessionFactory.isClosed()); @@ -367,4 +372,51 @@ public class HibernateProvider { return hibernateSessionFactory; } + public SessionFactory newSessionFactory(Configuration effectiveHibernateConfiguration) { + + hibernateSessionFactory = TopiaUtil.newSessionFactory(effectiveHibernateConfiguration); + + EventListenerRegistry eventListenerRegistry = getHibernateService(hibernateSessionFactory, EventListenerRegistry.class); + + TopiaHibernateEventListener listener = new TopiaHibernateEventListener(sessionRegistry); + eventListenerRegistry.appendListeners(EventType.PRE_INSERT, listener); + eventListenerRegistry.appendListeners(EventType.PRE_LOAD, listener); + eventListenerRegistry.appendListeners(EventType.PRE_UPDATE, listener); + eventListenerRegistry.appendListeners(EventType.PRE_DELETE, listener); + eventListenerRegistry.appendListeners(EventType.POST_INSERT, listener); + eventListenerRegistry.appendListeners(EventType.POST_LOAD, listener); + eventListenerRegistry.appendListeners(EventType.POST_UPDATE, listener); + eventListenerRegistry.appendListeners(EventType.POST_DELETE, listener); + + // following listeners must be called before hibernate + eventListenerRegistry.prependListeners(EventType.SAVE_UPDATE, listener); + + return hibernateSessionFactory; + } + + + public Metadata getMetaData() { + if (metaData == null) { + metaData = newMetaData(getHibernateConfiguration()); + } + return metaData; + } + + public Metadata newMetaData(Configuration configuration) { + return newMetaData(configuration, (Set) entityClasses); + } + + public Metadata newMetaData(Configuration configuration, Collection<Class<?>> entityClasses) { + + StandardServiceRegistry standardServiceRegistry = getStandardServiceRegistry(newSessionFactory(configuration)); + MetadataSources sources = new MetadataSources(standardServiceRegistry); + for (Class<?> persistanceClass : entityClasses) { + String hbmXmlFile = persistanceClass.getName().replace('.', '/') + ".hbm.xml"; + sources.addResource(hbmXmlFile); + } + + MetadataBuilder metadataBuilder = sources.getMetadataBuilder(); + + return metadataBuilder.build(); + } } diff --git a/topia-persistence/src/main/java/org/nuiton/topia/persistence/support/TopiaHibernateSupport.java b/topia-persistence/src/main/java/org/nuiton/topia/persistence/support/TopiaHibernateSupport.java index ff75dc0..280a302 100644 --- a/topia-persistence/src/main/java/org/nuiton/topia/persistence/support/TopiaHibernateSupport.java +++ b/topia-persistence/src/main/java/org/nuiton/topia/persistence/support/TopiaHibernateSupport.java @@ -26,6 +26,7 @@ package org.nuiton.topia.persistence.support; import org.hibernate.Session; import org.hibernate.SessionFactory; +import org.hibernate.boot.Metadata; import org.hibernate.cfg.Configuration; /** @@ -47,6 +48,11 @@ public interface TopiaHibernateSupport { SessionFactory getHibernateFactory(); /** + * @return Returns the Hibernate's Metadata. + */ + Metadata getHibernateMetadata(); + + /** * @return Returns the Hibernate configuration */ Configuration getHibernateConfiguration(); diff --git a/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaUtil.java b/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaUtil.java index 3440079..ae2eccd 100644 --- a/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaUtil.java +++ b/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaUtil.java @@ -33,6 +33,7 @@ import org.apache.commons.logging.LogFactory; import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.SessionFactory; +import org.hibernate.boot.Metadata; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.AvailableSettings; @@ -41,8 +42,6 @@ import org.hibernate.dialect.Dialect; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Table; -import org.hibernate.tool.hbm2ddl.DatabaseMetadata; -import org.hibernate.tool.hbm2ddl.TableMetadata; import org.nuiton.topia.persistence.SchemaValidationTopiaException; import org.nuiton.topia.persistence.TopiaEntity; import org.nuiton.topia.persistence.TopiaException; @@ -56,9 +55,10 @@ import java.io.Closeable; import java.io.IOException; import java.net.URL; import java.sql.Connection; +import java.sql.ResultSet; import java.sql.SQLException; +import java.util.Collection; import java.util.HashMap; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import java.util.Properties; @@ -174,8 +174,7 @@ public class TopiaUtil { * @return <tt>true</tt> si le schema de la table existe * @since 2.6.4 */ - public static boolean isSchemaExist(TopiaHibernateSupport topiaHibernateSupport, - String entityName) { + public static boolean isSchemaExist(TopiaHibernateSupport topiaHibernateSupport, String entityName) { ConnectionProviderSupplier connectionProviderSupplier = new ConnectionProviderSupplier(topiaHibernateSupport); @@ -183,45 +182,38 @@ public class TopiaUtil { try { - Configuration configuration = topiaHibernateSupport.getHibernateConfiguration(); - PersistentClass classMapping = - configuration.getClassMapping(entityName); + Metadata metadata = topiaHibernateSupport.getHibernateMetadata(); + PersistentClass classMapping = metadata.getEntityBinding(entityName); if (classMapping == null) { if (log.isInfoEnabled()) { - Iterator<?> itr = configuration.getClassMappings(); - while (itr.hasNext()) { - log.info("available mapping " + itr.next()); + Collection<PersistentClass> itr = metadata.getEntityBindings(); + for (PersistentClass persistentClass : itr) { + log.info("available mapping " + persistentClass); } } - throw new IllegalArgumentException( - "could not find entity with name " + entityName); + throw new IllegalArgumentException("could not find entity with name " + entityName); } Table testTable = classMapping.getTable(); if (testTable == null) { - throw new IllegalArgumentException( - "could not find entity with name " + entityName); + throw new IllegalArgumentException("could not find entity with name " + entityName); } - ConnectionProvider connectionProvider = - connectionProviderSupplier.get(); - - Dialect dialect = Dialect.getDialect(configuration.getProperties()); + ConnectionProvider connectionProvider = connectionProviderSupplier.get(); Connection connection = null; try { connection = connectionProvider.getConnection(); - DatabaseMetadata meta = new DatabaseMetadata(connection, dialect, configuration); - - TableMetadata tmd = meta.getTableMetadata( - testTable.getName(), testTable.getSchema(), - testTable.getCatalog(), testTable.isQuoted()); - - if (tmd != null) { - //table exist - exist = true; + ResultSet tables = connection.getMetaData().getTables(testTable.getCatalog(), testTable.getSchema(), null, null); + while (tables.next()) { + String currentTableName = tables.getString("TABLE_NAME"); + if (currentTableName.equalsIgnoreCase(testTable.getName())) { + exist = true; + } } + tables.close(); + } finally { connectionProvider.closeConnection(connection); } @@ -249,26 +241,20 @@ public class TopiaUtil { * @param entityName le nom de l'entite a tester * @return <tt>true</tt> si le schema de la table existe */ - public static boolean isSchemaExist(Configuration configuration, - String entityName) { + public static boolean isSchemaExist(Configuration configuration, Metadata metadata, String entityName) { - ConnectionProviderSupplier connectionProviderSupplier = - new ConnectionProviderSupplier(configuration); + ConnectionProviderSupplier connectionProviderSupplier = new ConnectionProviderSupplier(configuration); boolean exist = false; - try { - PersistentClass classMapping = - configuration.getClassMapping(entityName); + PersistentClass classMapping = metadata.getEntityBinding(entityName); if (classMapping == null) { if (log.isInfoEnabled()) { - Iterator<?> itr = configuration.getClassMappings(); - while (itr.hasNext()) { - log.info("available mapping " + itr.next()); + for (PersistentClass persistentClass : metadata.getEntityBindings()) { + log.info("available mapping " + persistentClass.getClassName()); } } - throw new IllegalArgumentException( - "could not find entity with name " + entityName); + throw new IllegalArgumentException("could not find entity with name " + entityName); } Table testTable = classMapping.getTable(); @@ -277,25 +263,21 @@ public class TopiaUtil { "could not find entity with name " + entityName); } - ConnectionProvider connectionProvider = - connectionProviderSupplier.get(); - - Dialect dialect = Dialect.getDialect(configuration.getProperties()); + ConnectionProvider connectionProvider = connectionProviderSupplier.get(); Connection connection = null; try { connection = connectionProvider.getConnection(); - DatabaseMetadata meta = new DatabaseMetadata(connection, dialect, configuration); - - TableMetadata tmd = meta.getTableMetadata( - testTable.getName(), testTable.getSchema(), - testTable.getCatalog(), testTable.isQuoted()); - - if (tmd != null) { - //table exist - exist = true; + ResultSet tables = connection.getMetaData().getTables(testTable.getCatalog(), testTable.getSchema(), null, null); + while (tables.next()) { + String currentTableName = tables.getString("TABLE_NAME"); + if (currentTableName.equalsIgnoreCase(testTable.getName())) { + exist = true; + } } + tables.close(); + } finally { connectionProvider.closeConnection(connection); } @@ -330,11 +312,12 @@ public class TopiaUtil { * the dealed entities. * * @param configuration hibernate db configuration + * @param metaData hibernate metadata * @return {@code true} if there is no schema for any of the dealed entities, * {@code false} otherwise. * @since 2.5.3 */ - public static boolean isSchemaEmpty(Configuration configuration) { + public static boolean isSchemaEmpty(Configuration configuration, Metadata metaData) { warnOnAutomaticSchemaOperationRisk(configuration); @@ -344,43 +327,28 @@ public class TopiaUtil { ConnectionProvider connectionProvider = connectionProviderSupplier.get(); - Dialect dialect = Dialect.getDialect(configuration.getProperties()); - Connection connection = null; try { connection = connectionProvider.getConnection(); - DatabaseMetadata meta = new DatabaseMetadata(connection, dialect, configuration); - - Iterator<?> itr = configuration.getClassMappings(); - while (itr.hasNext()) { - PersistentClass classMapping = (PersistentClass) itr.next(); - Table testTable = classMapping.getTable(); - - if (testTable == null) { - throw new IllegalArgumentException( - "could not find entity with name " + - classMapping.getClassName()); - } - + for (PersistentClass persistentClass : metaData.getEntityBindings()) { - TableMetadata tmd = meta.getTableMetadata( - testTable.getName(), testTable.getSchema(), - testTable.getCatalog(), testTable.isQuoted()); + Table testTable = persistentClass.getTable(); - if (tmd != null) { - //table exist + ResultSet tables = connection.getMetaData().getTables(testTable.getCatalog(), testTable.getSchema(), null, null); + while (tables.next()) { + String currentTableName = tables.getString("TABLE_NAME"); + log.trace("Scan table: " + currentTableName); + if (currentTableName.equalsIgnoreCase(testTable.getName())) { + if (log.isDebugEnabled()) { + log.debug("Existing table found " + testTable.getName() + " for entity " + + persistentClass.getClassName() + ", db is not empty."); + } - - if (log.isDebugEnabled()) { - log.debug("Existing table found " + - testTable.getName() + " for entity " + - classMapping.getClassName() + - ", db is not empty."); + return false; } - - return false; } + tables.close(); } } finally { @@ -414,48 +382,35 @@ public class TopiaUtil { ConnectionProviderSupplier connectionProviderSupplier = new ConnectionProviderSupplier(topiaHibernateSupport); Configuration configuration = topiaHibernateSupport.getHibernateConfiguration(); + Metadata metadata = topiaHibernateSupport.getHibernateMetadata(); try { - ConnectionProvider connectionProvider = - connectionProviderSupplier.get(); - - Dialect dialect = Dialect.getDialect(configuration.getProperties()); + ConnectionProvider connectionProvider = connectionProviderSupplier.get(); Connection connection = null; try { connection = connectionProvider.getConnection(); - DatabaseMetadata meta = new DatabaseMetadata(connection, dialect, configuration); - Iterator<?> itr = configuration.getClassMappings(); - while (itr.hasNext()) { - PersistentClass classMapping = (PersistentClass) itr.next(); - Table testTable = classMapping.getTable(); - - if (testTable == null) { - throw new IllegalArgumentException( - "could not find entity with name " + - classMapping.getClassName()); - } + for (PersistentClass persistentClass : metadata .getEntityBindings()) { + Table testTable = persistentClass.getTable(); - TableMetadata tmd = meta.getTableMetadata( - testTable.getName(), testTable.getSchema(), - testTable.getCatalog(), testTable.isQuoted()); + ResultSet tables = connection.getMetaData().getTables(testTable.getCatalog(), testTable.getSchema(), null, null); + while (tables.next()) { + String currentTableName = tables.getString("TABLE_NAME"); + log.trace("Scan table: " + currentTableName); + if (currentTableName.equalsIgnoreCase(testTable.getName())) { + if (log.isDebugEnabled()) { + log.debug("Existing table found " + testTable.getName() + " for entity " + + persistentClass.getClassName() + ", db is not empty."); + } - if (tmd != null) { - //table exist - - if (log.isDebugEnabled()) { - log.debug("Existing table found " + - testTable.getName() + " for entity " + - classMapping.getClassName() + - ", db is not empty."); + return false; } - - return false; } + tables.close(); } } finally { @@ -545,7 +500,7 @@ public class TopiaUtil { @Override public ConnectionProvider get() { if (connectionProvider == null) { - if (sessionFactory != null ) { + if (sessionFactory != null) { // If SessionFactory is provided, use the SessionFactoryServiceRegistry connectionProvider = HibernateProvider.getHibernateService(sessionFactory, ConnectionProvider.class); } else { diff --git a/topia-service-migration/src/main/java/org/nuiton/topia/migration/TopiaMigrationEngine.java b/topia-service-migration/src/main/java/org/nuiton/topia/migration/TopiaMigrationEngine.java index 5d107aa..b951d03 100644 --- a/topia-service-migration/src/main/java/org/nuiton/topia/migration/TopiaMigrationEngine.java +++ b/topia-service-migration/src/main/java/org/nuiton/topia/migration/TopiaMigrationEngine.java @@ -30,6 +30,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.Session; +import org.hibernate.boot.Metadata; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; import org.nuiton.topia.migration.mappings.TMSVersion; @@ -47,6 +48,7 @@ import org.nuiton.version.VersionComparator; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Properties; @@ -128,6 +130,8 @@ public class TopiaMigrationEngine implements TopiaMigrationService { */ protected boolean showProgression; + protected Metadata metaData; + // /** // * delegate context listener. // */ @@ -227,12 +231,14 @@ public class TopiaMigrationEngine implements TopiaMigrationService { // Create the dedicated Hibernate Configuration which is just about the TMSVersion entity in order to create // the table using schemaExport if necessary versionConfiguration = createTMSHibernateConfiguration(topiaApplicationContext); + versionConfiguration.getProperties().remove(AvailableSettings.HBM2DDL_AUTO); // Make sure schema is not created by Hibernate + + HibernateProvider hibernateProvider = ((AbstractTopiaApplicationContext) applicationContext).getHibernateProvider(); - // Now build the mapping and create TMSVersion table if necessary - versionConfiguration.buildMappings(); + metaData = hibernateProvider.newMetaData(versionConfiguration, Collections.<Class<?>>singleton(TMSVersion.class)); - if (applicationContext.getConfiguration().isInitSchema() && TopiaUtil.isSchemaEmpty(versionConfiguration)) { - TMSVersionHibernateDao.createTMSSchema(versionConfiguration); + if (applicationContext.getConfiguration().isInitSchema() && TopiaUtil.isSchemaEmpty(versionConfiguration, metaData)) { + TMSVersionHibernateDao.createTMSSchema(metaData); } // if (!migrateOnInit) { @@ -544,9 +550,8 @@ public class TopiaMigrationEngine implements TopiaMigrationService { try { // on vérifie que la table de versionning existe déjà - versionTableExist = - TopiaUtil.isSchemaExist(versionConfiguration, - TMSVersion.class.getName()); + versionTableExist = TopiaUtil.isSchemaExist(versionConfiguration,metaData, TMSVersion.class.getName()); + Preconditions.checkState(versionTableExist, "TMSVersion table should have be created during init"); @@ -603,9 +608,8 @@ public class TopiaMigrationEngine implements TopiaMigrationService { // Get a new Configuration instance (not initialized) Configuration applicationHibernateConfiguration = hibernateProvider.newHibernateConfiguration(); applicationHibernateConfiguration.getProperties().remove(AvailableSettings.HBM2DDL_AUTO); // Make sure schema is not created by Hibernate - applicationHibernateConfiguration.buildMappings(); - boolean result = TopiaUtil.isSchemaEmpty(applicationHibernateConfiguration); + boolean result = TopiaUtil.isSchemaEmpty(applicationHibernateConfiguration, metaData); return result; } diff --git a/topia-service-migration/src/main/java/org/nuiton/topia/migration/mappings/TMSVersionHibernateDao.java b/topia-service-migration/src/main/java/org/nuiton/topia/migration/mappings/TMSVersionHibernateDao.java index bd3f10b..b7bbe1c 100644 --- a/topia-service-migration/src/main/java/org/nuiton/topia/migration/mappings/TMSVersionHibernateDao.java +++ b/topia-service-migration/src/main/java/org/nuiton/topia/migration/mappings/TMSVersionHibernateDao.java @@ -29,9 +29,11 @@ import org.apache.commons.logging.LogFactory; import org.hibernate.Criteria; import org.hibernate.HibernateException; import org.hibernate.Session; +import org.hibernate.boot.Metadata; import org.hibernate.cfg.Configuration; import org.hibernate.jdbc.Work; import org.hibernate.tool.hbm2ddl.SchemaExport; +import org.hibernate.tool.schema.TargetType; import org.nuiton.topia.persistence.TopiaException; import org.nuiton.topia.persistence.util.TopiaUtil; import org.nuiton.version.Version; @@ -41,6 +43,7 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.EnumSet; import java.util.List; /** @@ -72,18 +75,26 @@ public class TMSVersionHibernateDao { } } - public static void createTMSSchema(Configuration configuration) { + public static void createTMSSchema(Metadata metadata) { // creer le schema en base // dans la configuration il n'y a que la table version - SchemaExport schemaExport = new SchemaExport(configuration); - schemaExport.create(log.isDebugEnabled(), true); + SchemaExport schemaExport = new SchemaExport(); + EnumSet<TargetType> targetTypes = EnumSet.of(TargetType.DATABASE); + if (log.isDebugEnabled()) { + targetTypes.add(TargetType.STDOUT); + } + schemaExport.create(targetTypes, metadata); } - public static void dropTMSSchema(Configuration configuration) { + public static void dropTMSSchema(Metadata metadata) { // supprimer le schema en base // dans la configuration il n'y a que la table version - SchemaExport schemaExport = new SchemaExport(configuration); - schemaExport.drop(log.isDebugEnabled(), true); + SchemaExport schemaExport = new SchemaExport(); + EnumSet<TargetType> targetTypes = EnumSet.of(TargetType.DATABASE); + if (log.isDebugEnabled()) { + targetTypes.add(TargetType.STDOUT); + } + schemaExport.drop(targetTypes,metadata); } public static TMSVersion saveVersion(Session session, String version) throws TopiaException { -- 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/4062 in repository topia. See https://gitlab.nuiton.org/nuiton/topia.git commit 1e1f0dcb65093a483c350c6c8d3dcd1ae3cb0cac Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Oct 18 17:23:09 2016 +0200 Fix tests by preventing validation while testing TopiaUtil --- .../test/java/org/nuiton/topia/it/legacy/framework/TopiaUtilTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/topia-it/src/test/java/org/nuiton/topia/it/legacy/framework/TopiaUtilTest.java b/topia-it/src/test/java/org/nuiton/topia/it/legacy/framework/TopiaUtilTest.java index d095150..03d82c2 100644 --- a/topia-it/src/test/java/org/nuiton/topia/it/legacy/framework/TopiaUtilTest.java +++ b/topia-it/src/test/java/org/nuiton/topia/it/legacy/framework/TopiaUtilTest.java @@ -62,6 +62,7 @@ public class TopiaUtilTest { protected TopiaItLegacyTopiaApplicationContext createApplicationContext(TopiaConfiguration topiaConfiguration) { BeanTopiaConfiguration configuration = new TopiaConfigurationBuilder().copyOf(topiaConfiguration); configuration.setInitSchema(false); + configuration.setValidateSchema(false); return super.createApplicationContext(configuration); } }; -- 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/4062 in repository topia. See https://gitlab.nuiton.org/nuiton/topia.git commit 4985b2dfc9bce5ff43f284b05105791c65906fa8 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Oct 23 11:16:37 2016 +0200 Fix dao detection --- .../internal/AbstractTopiaPersistenceContext.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/AbstractTopiaPersistenceContext.java b/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/AbstractTopiaPersistenceContext.java index fb944dd..3ee00a4 100644 --- a/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/AbstractTopiaPersistenceContext.java +++ b/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/AbstractTopiaPersistenceContext.java @@ -49,6 +49,7 @@ import org.nuiton.topia.persistence.support.TopiaHibernateSupport; import org.nuiton.topia.persistence.support.TopiaJpaSupport; import org.nuiton.topia.persistence.support.TopiaSqlSupport; +import javax.persistence.metamodel.EntityType; import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.Map; @@ -281,21 +282,21 @@ public abstract class AbstractTopiaPersistenceContext implements TopiaPersistenc boolean found = false; try { - hibernateFactory.getMetamodel().entity(entityClass); - found = true; + EntityType<E> entity = hibernateFactory.getMetamodel().entity(entityClass); + found = entity != null; } catch (Exception e) { } if (!found) { try { - hibernateFactory.getMetamodel().entity(entityClass.getName() + "Impl"); - found = true; + EntityType<Object> entity = hibernateFactory.getMetamodel().entity(entityClass.getName() + "Impl"); + found = entity != null; } catch (Exception e) { } } if (!found) { try { - hibernateFactory.getMetamodel().entity(entityClass.getName() + "Abstract"); - found = true; + EntityType<Object> entity = hibernateFactory.getMetamodel().entity(entityClass.getName() + "Abstract"); + found = entity != null; } catch (Exception e) { } } -- 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/4062 in repository topia. See https://gitlab.nuiton.org/nuiton/topia.git commit dccf8d731f38a65fc8c4b4e0ebdfbdb2e62c4bc2 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Oct 23 11:18:35 2016 +0200 Add persistent classes to configuration (otherwise sessionFactory do not know them) + review newSessionFactory method --- .../java/org/nuiton/topia/persistence/internal/HibernateProvider.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/HibernateProvider.java b/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/HibernateProvider.java index faf2574..bc1667f 100644 --- a/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/HibernateProvider.java +++ b/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/HibernateProvider.java @@ -374,7 +374,7 @@ public class HibernateProvider { public SessionFactory newSessionFactory(Configuration effectiveHibernateConfiguration) { - hibernateSessionFactory = TopiaUtil.newSessionFactory(effectiveHibernateConfiguration); + SessionFactory hibernateSessionFactory = TopiaUtil.newSessionFactory(effectiveHibernateConfiguration); EventListenerRegistry eventListenerRegistry = getHibernateService(hibernateSessionFactory, EventListenerRegistry.class); @@ -413,6 +413,7 @@ public class HibernateProvider { for (Class<?> persistanceClass : entityClasses) { String hbmXmlFile = persistanceClass.getName().replace('.', '/') + ".hbm.xml"; sources.addResource(hbmXmlFile); + configuration.addClass(persistanceClass); } MetadataBuilder metadataBuilder = sources.getMetadataBuilder(); -- 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/4062 in repository topia. See https://gitlab.nuiton.org/nuiton/topia.git commit a6d3be272839c7d8ddcf303b1c0a1b55735a29fa Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Oct 23 15:59:34 2016 +0200 Hibernate 5 requires java 8 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index a373e8f..29ac803 100644 --- a/pom.xml +++ b/pom.xml @@ -243,8 +243,8 @@ <siteSourcesType>rst</siteSourcesType> <ciViewId>ToPIA</ciViewId> - <javaVersion>1.7</javaVersion> - <signatureArtifactId>java17</signatureArtifactId> + <javaVersion>1.8</javaVersion> + <signatureArtifactId>java18</signatureArtifactId> <signatureVersion>1.0</signatureVersion> </properties> -- 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/4062 in repository topia. See https://gitlab.nuiton.org/nuiton/topia.git commit 061b98f70e2fd0badb40c0cb7f16a34c8f8532c6 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Oct 23 16:21:33 2016 +0200 Optimize dependencies --- pom.xml | 6 ++++++ topia-it/pom.xml | 4 ++++ topia-persistence/pom.xml | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/pom.xml b/pom.xml index 29ac803..6092176 100644 --- a/pom.xml +++ b/pom.xml @@ -308,6 +308,12 @@ </dependency> <dependency> + <groupId>org.hibernate.javax.persistence</groupId> + <artifactId>hibernate-jpa-2.1-api</artifactId> + <version>1.0.0.Final</version> + </dependency> + + <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-ehcache</artifactId> <version>${hibernateVersion}</version> diff --git a/topia-it/pom.xml b/topia-it/pom.xml index 903d4b3..1bd0dd1 100644 --- a/topia-it/pom.xml +++ b/topia-it/pom.xml @@ -79,6 +79,10 @@ <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> </dependency> + <dependency> + <groupId>org.hibernate.javax.persistence</groupId> + <artifactId>hibernate-jpa-2.1-api</artifactId> + </dependency> <dependency> <groupId>org.apache.commons</groupId> diff --git a/topia-persistence/pom.xml b/topia-persistence/pom.xml index 8b3015f..8bfa789 100644 --- a/topia-persistence/pom.xml +++ b/topia-persistence/pom.xml @@ -91,6 +91,10 @@ <groupId>org.hibernate</groupId> <artifactId>hibernate-ehcache</artifactId> </dependency> + <dependency> + <groupId>org.hibernate.javax.persistence</groupId> + <artifactId>hibernate-jpa-2.1-api</artifactId> + </dependency> <dependency> <groupId>org.javassist</groupId> -- 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/4062 in repository topia. See https://gitlab.nuiton.org/nuiton/topia.git commit a3f23951a314caa402868d2e876f0b1d629723f5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Oct 23 16:21:51 2016 +0200 optimize third parties --- topia-it/src/license/THIRD-PARTY.properties | 15 ++++++++------- topia-junit/src/license/THIRD-PARTY.properties | 15 ++++++++------- topia-persistence/src/license/THIRD-PARTY.properties | 19 ++++++++++--------- topia-service-csv/src/license/THIRD-PARTY.properties | 14 ++++++++------ .../src/license/THIRD-PARTY.properties | 12 +++++------- .../src/license/THIRD-PARTY.properties | 12 +++++------- .../src/license/THIRD-PARTY.properties | 13 ++++++++----- .../src/license/THIRD-PARTY.properties | 13 ++++++++----- topia-templates/src/license/THIRD-PARTY.properties | 16 ++++++++-------- 9 files changed, 68 insertions(+), 61 deletions(-) diff --git a/topia-it/src/license/THIRD-PARTY.properties b/topia-it/src/license/THIRD-PARTY.properties index 1d51c61..6c8c0d1 100644 --- a/topia-it/src/license/THIRD-PARTY.properties +++ b/topia-it/src/license/THIRD-PARTY.properties @@ -2,13 +2,14 @@ #------------------------------------------------------------------------------- # Already used licenses in project : # - Apache License 2.0 +# - Apache License, version 2.0 # - BSD License # - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 -# - Common Development and Distribution License -# - Common Public License Version 1.0 -# - GNU General Public License, Version 2 with the Classpath Exception -# - GNU Lesser General Public License, version 2.1 -# - GNU Library or Lesser General Public License +# - Eclipse Distribution License (EDL), Version 1.0 +# - Eclipse Public License (EPL), Version 1.0 +# - Eclipse Public License 1.0 +# - Eclipse Public License, Version 1.0 +# - GNU Lesser General Public License, Version 2.1 # - Indiana University Extreme! Lab Software License, vesion 1.1.1 # - Lesser General Public License (LGPL) v 3.0 # - Lesser General Public License (LPGL) @@ -18,11 +19,11 @@ # - New BSD License # - The Apache Software License, Version 2.0 # - The H2 License, Version 1.0 -# - license.txt #------------------------------------------------------------------------------- # Please fill the missing licenses for dependencies : # # -#Tue Dec 03 18:48:59 CET 2013 +#Sun Oct 23 16:07:54 CEST 2016 commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0 dom4j--dom4j--1.6.1=BSD License +javax.el--el-api--2.2=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 diff --git a/topia-junit/src/license/THIRD-PARTY.properties b/topia-junit/src/license/THIRD-PARTY.properties index 4fb1227..c0aee1b 100644 --- a/topia-junit/src/license/THIRD-PARTY.properties +++ b/topia-junit/src/license/THIRD-PARTY.properties @@ -2,13 +2,14 @@ #------------------------------------------------------------------------------- # Already used licenses in project : # - Apache License 2.0 +# - Apache License, version 2.0 # - BSD License # - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 -# - Common Development and Distribution License -# - Common Public License Version 1.0 -# - GNU General Public License, Version 2 with the Classpath Exception -# - GNU Lesser General Public License, version 2.1 -# - GNU Library or Lesser General Public License +# - Eclipse Distribution License (EDL), Version 1.0 +# - Eclipse Public License (EPL), Version 1.0 +# - Eclipse Public License 1.0 +# - Eclipse Public License, Version 1.0 +# - GNU Lesser General Public License, Version 2.1 # - Indiana University Extreme! Lab Software License, vesion 1.1.1 # - Lesser General Public License (LGPL) v 3.0 # - Lesser General Public License (LPGL) @@ -18,11 +19,11 @@ # - New BSD License # - The Apache Software License, Version 2.0 # - The H2 License, Version 1.0 -# - license.txt #------------------------------------------------------------------------------- # Please fill the missing licenses for dependencies : # # -#Tue Dec 03 18:48:40 CET 2013 +#Sun Oct 23 16:07:32 CEST 2016 commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0 dom4j--dom4j--1.6.1=BSD License +javax.el--el-api--2.2=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 diff --git a/topia-persistence/src/license/THIRD-PARTY.properties b/topia-persistence/src/license/THIRD-PARTY.properties index db4a80f..4ba0c73 100644 --- a/topia-persistence/src/license/THIRD-PARTY.properties +++ b/topia-persistence/src/license/THIRD-PARTY.properties @@ -1,30 +1,31 @@ # Generated by org.codehaus.mojo.license.AddThirdPartyMojo #------------------------------------------------------------------------------- # Already used licenses in project : +# - Apache 2 # - Apache License 2.0 +# - Apache License, version 2.0 # - BSD License # - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 -# - Common Public License Version 1.0 -# - GNU Lesser General Public License, version 2.1 -# - GNU Library or Lesser General Public License +# - Eclipse Distribution License (EDL), Version 1.0 +# - Eclipse Public License (EPL), Version 1.0 +# - Eclipse Public License 1.0 +# - Eclipse Public License, Version 1.0 +# - GNU Lesser General Public License, Version 2.1 # - Indiana University Extreme! Lab Software License, vesion 1.1.1 # - Lesser General Public License (LGPL) v 3.0 # - Lesser General Public License (LPGL) # - Lesser General Public License (LPGL) v 2.1 # - MIT License # - MPL 1.1 -# - Mozilla Public License Version 1.0 # - New BSD License # - The Apache Software License, Version 2.0 # - The H2 License, Version 1.0 -# - The SAX License -# - The W3C License -# - http://jaxen.codehaus.org/license.html -# - license.txt +# - The MIT License #------------------------------------------------------------------------------- # Please fill the missing licenses for dependencies : # # -#Fri Mar 15 12:36:23 CET 2013 +#Sun Oct 23 16:02:31 CEST 2016 commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0 dom4j--dom4j--1.6.1=BSD License +javax.el--el-api--2.2=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 diff --git a/topia-service-csv/src/license/THIRD-PARTY.properties b/topia-service-csv/src/license/THIRD-PARTY.properties index 712f08e..acc90ec 100644 --- a/topia-service-csv/src/license/THIRD-PARTY.properties +++ b/topia-service-csv/src/license/THIRD-PARTY.properties @@ -2,12 +2,14 @@ #------------------------------------------------------------------------------- # Already used licenses in project : # - Apache License 2.0 +# - Apache License, version 2.0 # - BSD License # - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 -# - Common Development and Distribution License -# - Common Public License Version 1.0 -# - GNU General Public License, Version 2 with the Classpath Exception -# - GNU Lesser General Public License, version 2.1 +# - Eclipse Distribution License (EDL), Version 1.0 +# - Eclipse Public License (EPL), Version 1.0 +# - Eclipse Public License 1.0 +# - Eclipse Public License, Version 1.0 +# - GNU Lesser General Public License, Version 2.1 # - GNU Library or Lesser General Public License # - Indiana University Extreme! Lab Software License, vesion 1.1.1 # - Lesser General Public License (LGPL) v 3.0 @@ -18,11 +20,11 @@ # - New BSD License # - The Apache Software License, Version 2.0 # - The H2 License, Version 1.0 -# - license.txt #------------------------------------------------------------------------------- # Please fill the missing licenses for dependencies : # # -#Mon Jan 06 17:24:26 CET 2014 +#Sun Oct 23 16:17:24 CEST 2016 commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0 dom4j--dom4j--1.6.1=BSD License +javax.el--el-api--2.2=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 diff --git a/topia-service-flyway/src/license/THIRD-PARTY.properties b/topia-service-flyway/src/license/THIRD-PARTY.properties index de75866..e62c17f 100644 --- a/topia-service-flyway/src/license/THIRD-PARTY.properties +++ b/topia-service-flyway/src/license/THIRD-PARTY.properties @@ -1,16 +1,15 @@ # Generated by org.codehaus.mojo.license.AddThirdPartyMojo #------------------------------------------------------------------------------- # Already used licenses in project : -# - AL 2.0 # - Apache License 2.0 # - Apache License, version 2.0 # - BSD License # - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 -# - Common Development and Distribution License -# - Common Public License Version 1.0 # - Eclipse Distribution License (EDL), Version 1.0 # - Eclipse Public License (EPL), Version 1.0 -# - GNU General Public License, Version 2 with the Classpath Exception +# - Eclipse Public License 1.0 +# - Eclipse Public License, Version 1.0 +# - GNU Lesser General Public License, Version 2.1 # - Indiana University Extreme! Lab Software License, vesion 1.1.1 # - Lesser General Public License (LGPL) v 3.0 # - Lesser General Public License (LPGL) @@ -18,14 +17,13 @@ # - MIT License # - MPL 1.1 # - New BSD License -# - Public Domain # - The Apache Software License, Version 2.0 # - The H2 License, Version 1.0 #------------------------------------------------------------------------------- # Please fill the missing licenses for dependencies : # # -#Wed Jun 04 11:22:29 CEST 2014 +#Sun Oct 23 16:17:13 CEST 2016 commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0 dom4j--dom4j--1.6.1=BSD License - +javax.el--el-api--2.2=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 diff --git a/topia-service-liquibase/src/license/THIRD-PARTY.properties b/topia-service-liquibase/src/license/THIRD-PARTY.properties index 6d7d3c4..778bfd6 100644 --- a/topia-service-liquibase/src/license/THIRD-PARTY.properties +++ b/topia-service-liquibase/src/license/THIRD-PARTY.properties @@ -1,17 +1,16 @@ # Generated by org.codehaus.mojo.license.AddThirdPartyMojo #------------------------------------------------------------------------------- # Already used licenses in project : -# - AL 2.0 # - Apache License 2.0 # - Apache License Version 2.0 # - Apache License, version 2.0 # - BSD License # - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 -# - Common Development and Distribution License -# - Common Public License Version 1.0 # - Eclipse Distribution License (EDL), Version 1.0 # - Eclipse Public License (EPL), Version 1.0 -# - GNU General Public License, Version 2 with the Classpath Exception +# - Eclipse Public License 1.0 +# - Eclipse Public License, Version 1.0 +# - GNU Lesser General Public License, Version 2.1 # - Indiana University Extreme! Lab Software License, vesion 1.1.1 # - Lesser General Public License (LGPL) v 3.0 # - Lesser General Public License (LPGL) @@ -19,14 +18,13 @@ # - MIT License # - MPL 1.1 # - New BSD License -# - Public Domain # - The Apache Software License, Version 2.0 # - The H2 License, Version 1.0 #------------------------------------------------------------------------------- # Please fill the missing licenses for dependencies : # # -#Wed Jun 04 11:22:32 CEST 2014 +#Sun Oct 23 16:17:19 CEST 2016 commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0 dom4j--dom4j--1.6.1=BSD License - +javax.el--el-api--2.2=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 diff --git a/topia-service-migration/src/license/THIRD-PARTY.properties b/topia-service-migration/src/license/THIRD-PARTY.properties index 2427d6c..d97276c 100644 --- a/topia-service-migration/src/license/THIRD-PARTY.properties +++ b/topia-service-migration/src/license/THIRD-PARTY.properties @@ -2,11 +2,14 @@ #------------------------------------------------------------------------------- # Already used licenses in project : # - Apache License 2.0 +# - Apache License, version 2.0 # - BSD License # - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 -# - Common Public License Version 1.0 -# - GNU Lesser General Public License, version 2.1 -# - GNU Library or Lesser General Public License +# - Eclipse Distribution License (EDL), Version 1.0 +# - Eclipse Public License (EPL), Version 1.0 +# - Eclipse Public License 1.0 +# - Eclipse Public License, Version 1.0 +# - GNU Lesser General Public License, Version 2.1 # - Indiana University Extreme! Lab Software License, vesion 1.1.1 # - Lesser General Public License (LGPL) v 3.0 # - Lesser General Public License (LPGL) @@ -16,11 +19,11 @@ # - New BSD License # - The Apache Software License, Version 2.0 # - The H2 License, Version 1.0 -# - license.txt #------------------------------------------------------------------------------- # Please fill the missing licenses for dependencies : # # -#Fri Mar 15 12:42:01 CET 2013 +#Sun Oct 23 16:17:04 CEST 2016 commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0 dom4j--dom4j--1.6.1=BSD License +javax.el--el-api--2.2=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 diff --git a/topia-service-replication/src/license/THIRD-PARTY.properties b/topia-service-replication/src/license/THIRD-PARTY.properties index b1d20ff..1525ce2 100644 --- a/topia-service-replication/src/license/THIRD-PARTY.properties +++ b/topia-service-replication/src/license/THIRD-PARTY.properties @@ -2,11 +2,14 @@ #------------------------------------------------------------------------------- # Already used licenses in project : # - Apache License 2.0 +# - Apache License, version 2.0 # - BSD License # - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 -# - Common Public License Version 1.0 -# - GNU Lesser General Public License, version 2.1 -# - GNU Library or Lesser General Public License +# - Eclipse Distribution License (EDL), Version 1.0 +# - Eclipse Public License (EPL), Version 1.0 +# - Eclipse Public License 1.0 +# - Eclipse Public License, Version 1.0 +# - GNU Lesser General Public License, Version 2.1 # - Indiana University Extreme! Lab Software License, vesion 1.1.1 # - Lesser General Public License (LGPL) v 3.0 # - Lesser General Public License (LPGL) @@ -16,11 +19,11 @@ # - New BSD License # - The Apache Software License, Version 2.0 # - The H2 License, Version 1.0 -# - license.txt #------------------------------------------------------------------------------- # Please fill the missing licenses for dependencies : # # -#Fri Mar 15 12:41:29 CET 2013 +#Sun Oct 23 16:15:31 CEST 2016 commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0 dom4j--dom4j--1.6.1=BSD License +javax.el--el-api--2.2=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 diff --git a/topia-templates/src/license/THIRD-PARTY.properties b/topia-templates/src/license/THIRD-PARTY.properties index 77834de..0813d19 100644 --- a/topia-templates/src/license/THIRD-PARTY.properties +++ b/topia-templates/src/license/THIRD-PARTY.properties @@ -2,14 +2,14 @@ #------------------------------------------------------------------------------- # Already used licenses in project : # - Apache License 2.0 -# - Apache License Version 2.0 +# - Apache License, version 2.0 # - BSD License # - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 -# - Common Development and Distribution License -# - Common Public License Version 1.0 -# - GNU General Public License, Version 2 with the Classpath Exception -# - GNU Lesser General Public License, version 2.1 -# - GNU Library or Lesser General Public License +# - Eclipse Distribution License (EDL), Version 1.0 +# - Eclipse Public License (EPL), Version 1.0 +# - Eclipse Public License 1.0 +# - Eclipse Public License, Version 1.0 +# - GNU Lesser General Public License, Version 2.1 # - Indiana University Extreme! Lab Software License, vesion 1.1.1 # - Lesser General Public License (LGPL) v 3.0 # - Lesser General Public License (LPGL) @@ -21,11 +21,11 @@ # - The Apache Software License, Version 2.0 # - The H2 License, Version 1.0 # - http://jaxen.codehaus.org/license.html -# - license.txt #------------------------------------------------------------------------------- # Please fill the missing licenses for dependencies : # # -#Tue Dec 03 18:48:47 CET 2013 +#Sun Oct 23 16:07:39 CEST 2016 commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0 dom4j--dom4j--1.6.1=BSD License +javax.el--el-api--2.2=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 -- 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/4062 in repository topia. See https://gitlab.nuiton.org/nuiton/topia.git commit 763e62bf270dcde1f3efecc231504bdf8a231b4f Author: Tony CHEMIT <chemit@codelutin.com> Date: Thu Dec 15 11:31:52 2016 +0100 refs #4062 Go back to hibernate 5.1.3 to stay on java 7 --- pom.xml | 6 +-- .../internal/AbstractTopiaPersistenceContext.java | 51 +++++++++++----------- .../nuiton/topia/persistence/util/TopiaUtil.java | 21 ++++----- .../migration/AbstractTopiaMigrationCallback.java | 3 +- 4 files changed, 41 insertions(+), 40 deletions(-) diff --git a/pom.xml b/pom.xml index 6092176..92b277c 100644 --- a/pom.xml +++ b/pom.xml @@ -225,7 +225,7 @@ <h2Version>1.3.176</h2Version> <hamcrestVersion>1.3</hamcrestVersion> - <hibernateVersion>5.2.3.Final</hibernateVersion> + <hibernateVersion>5.1.3.Final</hibernateVersion> <javassistVersion>3.20.0-GA</javassistVersion> <junitVersion>4.12</junitVersion> <liquibaseVersion>3.5.3</liquibaseVersion> @@ -243,8 +243,8 @@ <siteSourcesType>rst</siteSourcesType> <ciViewId>ToPIA</ciViewId> - <javaVersion>1.8</javaVersion> - <signatureArtifactId>java18</signatureArtifactId> + <javaVersion>1.7</javaVersion> + <signatureArtifactId>java17</signatureArtifactId> <signatureVersion>1.0</signatureVersion> </properties> diff --git a/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/AbstractTopiaPersistenceContext.java b/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/AbstractTopiaPersistenceContext.java index 3ee00a4..d1785fa 100644 --- a/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/AbstractTopiaPersistenceContext.java +++ b/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/AbstractTopiaPersistenceContext.java @@ -49,7 +49,6 @@ import org.nuiton.topia.persistence.support.TopiaHibernateSupport; import org.nuiton.topia.persistence.support.TopiaJpaSupport; import org.nuiton.topia.persistence.support.TopiaSqlSupport; -import javax.persistence.metamodel.EntityType; import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.Map; @@ -280,36 +279,36 @@ public abstract class AbstractTopiaPersistenceContext implements TopiaPersistenc SessionFactory hibernateFactory = hibernateSupport.getHibernateFactory(); Preconditions.checkState(hibernateFactory != null, "The Hibernate SessionFactory is null, please initialize"); - boolean found = false; - try { - EntityType<E> entity = hibernateFactory.getMetamodel().entity(entityClass); - found = entity != null; - } catch (Exception e) { - } - if (!found) { - try { - EntityType<Object> entity = hibernateFactory.getMetamodel().entity(entityClass.getName() + "Impl"); - found = entity != null; - } catch (Exception e) { - } - } - if (!found) { - try { - EntityType<Object> entity = hibernateFactory.getMetamodel().entity(entityClass.getName() + "Abstract"); - found = entity != null; - } catch (Exception e) { - } - } - -// if (hibernateFactory.getMetamodel().entity(entityClass) == null && -// hibernateFactory.getMetamodel().entity(entityClass.getName() + "Impl") == null && -// hibernateFactory.getMetamodel().entity(entityClass.getName() + "Abstract") == null) + //TODO Use this code for hibernate >= 5.2 +// boolean found = false; +// try { +// EntityType<E> entity = hibernateFactory.getClassMetadata(entityClass).; +// found = entity != null; +// } catch (Exception e) { +// } +// if (!found) { +// try { +// EntityType<Object> entity = hibernateFactory.getMetamodel().entity(entityClass.getName() + "Impl"); +// found = entity != null; +// } catch (Exception e) { +// } +// } +// if (!found) { +// try { +// EntityType<Object> entity = hibernateFactory.getMetamodel().entity(entityClass.getName() + "Abstract"); +// found = entity != null; +// } catch (Exception e) { +// } +// } + + boolean found = hibernateFactory.getClassMetadata(entityClass.getName() + "Impl") != null + || hibernateFactory.getClassMetadata(entityClass.getName() + "Abstract") != null; if (! found) { if (log.isInfoEnabled()) { String format = "List of supported persistence classes: %s"; - String message = String.format(format, hibernateFactory.getMetamodel().getEntities()); + String message = String.format(format, hibernateFactory.getAllClassMetadata().values()); log.info(message); } String format = "The following entity type %s is not managed by this context, you probably forgot to declare it."; diff --git a/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaUtil.java b/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaUtil.java index ae2eccd..5975c05 100644 --- a/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaUtil.java +++ b/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaUtil.java @@ -38,10 +38,10 @@ import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; -import org.hibernate.dialect.Dialect; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Table; +import org.hibernate.resource.transaction.spi.TransactionStatus; import org.nuiton.topia.persistence.SchemaValidationTopiaException; import org.nuiton.topia.persistence.TopiaEntity; import org.nuiton.topia.persistence.TopiaException; @@ -301,7 +301,7 @@ public class TopiaUtil { String hbm2ddl = configuration.getProperties().getProperty(AvailableSettings.HBM2DDL_AUTO); if (ImmutableSet.of("update", "create", "create-drop").contains(hbm2ddl)) { log.warn(String.format("Be careful, you are about to let Hibernate automatically create or update " + - "your database schema. [%s=%s]", AvailableSettings.HBM2DDL_AUTO, hbm2ddl)); + "your database schema. [%s=%s]", AvailableSettings.HBM2DDL_AUTO, hbm2ddl)); } } @@ -312,7 +312,7 @@ public class TopiaUtil { * the dealed entities. * * @param configuration hibernate db configuration - * @param metaData hibernate metadata + * @param metaData hibernate metadata * @return {@code true} if there is no schema for any of the dealed entities, * {@code false} otherwise. * @since 2.5.3 @@ -342,7 +342,7 @@ public class TopiaUtil { if (currentTableName.equalsIgnoreCase(testTable.getName())) { if (log.isDebugEnabled()) { log.debug("Existing table found " + testTable.getName() + " for entity " + - persistentClass.getClassName() + ", db is not empty."); + persistentClass.getClassName() + ", db is not empty."); } return false; @@ -393,7 +393,7 @@ public class TopiaUtil { connection = connectionProvider.getConnection(); - for (PersistentClass persistentClass : metadata .getEntityBindings()) { + for (PersistentClass persistentClass : metadata.getEntityBindings()) { Table testTable = persistentClass.getTable(); @@ -404,7 +404,7 @@ public class TopiaUtil { if (currentTableName.equalsIgnoreCase(testTable.getName())) { if (log.isDebugEnabled()) { log.debug("Existing table found " + testTable.getName() + " for entity " + - persistentClass.getClassName() + ", db is not empty."); + persistentClass.getClassName() + ", db is not empty."); } return false; @@ -443,9 +443,9 @@ public class TopiaUtil { public static Map<String, Object> convertPropertiesArrayToMap(Object... propertyNamesAndValues) throws IllegalArgumentException { int propertiesLength = propertyNamesAndValues.length; Preconditions.checkArgument(propertiesLength % 2 == 0, - "Wrong number of argument " - + propertiesLength - + ", you must have even number."); + "Wrong number of argument " + + propertiesLength + + ", you must have even number."); Map<String, Object> properties = new LinkedHashMap<String, Object>(); for (int i = 0; i < propertyNamesAndValues.length; ) { Object aPropertyName = propertyNamesAndValues[i++]; @@ -525,6 +525,7 @@ public class TopiaUtil { /** * Builds a new instance of Hibernate SessionFactory according to the given Hibernate Configuration + * * @param hibernateConfiguration an initialized Hibernate Configuration * @return an instance of SessionFactory */ @@ -577,7 +578,7 @@ public class TopiaUtil { if (log.isErrorEnabled()) { log.error("Exception during Hibernate session usage, rollbacking transaction", eee); } - if (session != null && session.isOpen() && session.getTransaction().isActive()) { + if (session != null && session.isOpen() && TransactionStatus.ACTIVE == session.getTransaction().getStatus()) { session.getTransaction().rollback(); } throw new TopiaException("Exception during Hibernate session usage", eee); diff --git a/topia-service-migration/src/main/java/org/nuiton/topia/migration/AbstractTopiaMigrationCallback.java b/topia-service-migration/src/main/java/org/nuiton/topia/migration/AbstractTopiaMigrationCallback.java index 73f2b76..f166c5d 100644 --- a/topia-service-migration/src/main/java/org/nuiton/topia/migration/AbstractTopiaMigrationCallback.java +++ b/topia-service-migration/src/main/java/org/nuiton/topia/migration/AbstractTopiaMigrationCallback.java @@ -29,6 +29,7 @@ import org.apache.commons.logging.LogFactory; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; +import org.hibernate.resource.transaction.spi.TransactionStatus; import org.nuiton.topia.migration.mappings.TMSVersionHibernateDao; import org.nuiton.topia.persistence.TopiaException; import org.nuiton.topia.persistence.internal.support.HibernateTopiaSqlSupport; @@ -129,7 +130,7 @@ public abstract class AbstractTopiaMigrationCallback { if (log.isDebugEnabled()) { log.error("Exception during schema migration, rollbacking transaction", eee); } - if (session != null && session.isOpen() && session.getTransaction().isActive()) { + if (session != null && session.isOpen() && TransactionStatus.ACTIVE == session.getTransaction().getStatus()) { session.getTransaction().rollback(); } throw new TopiaException("Exception during schema migration", eee); -- 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/4062 in repository topia. See https://gitlab.nuiton.org/nuiton/topia.git commit d71c50ac63e3d2fe7aaa085bf190a72fda796afc Author: Tony CHEMIT <chemit@codelutin.com> Date: Thu Dec 15 11:32:32 2016 +0100 refs #4062 Fix the shcema validation exception hack :( --- .../nuiton/topia/persistence/SchemaValidationTopiaException.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/topia-persistence/src/main/java/org/nuiton/topia/persistence/SchemaValidationTopiaException.java b/topia-persistence/src/main/java/org/nuiton/topia/persistence/SchemaValidationTopiaException.java index 65a3f2c..d11fca3 100644 --- a/topia-persistence/src/main/java/org/nuiton/topia/persistence/SchemaValidationTopiaException.java +++ b/topia-persistence/src/main/java/org/nuiton/topia/persistence/SchemaValidationTopiaException.java @@ -25,7 +25,7 @@ package org.nuiton.topia.persistence; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import org.hibernate.HibernateException; -import org.hibernate.tool.hbm2ddl.SchemaValidator; +import org.hibernate.tool.schema.internal.SchemaValidatorImpl; import java.util.Arrays; @@ -46,8 +46,8 @@ public class SchemaValidationTopiaException extends TopiaException { @Override public boolean apply(StackTraceElement input) { - return input.getClassName().equals(SchemaValidator.class.getName()) - && input.getMethodName().equals("validate"); + return input.getClassName().equals(SchemaValidatorImpl.class.getName()) + && input.getMethodName().equals("doValidation"); } }; @@ -57,7 +57,8 @@ public class SchemaValidationTopiaException extends TopiaException { /** * If given {@link HibernateException} is about schema validation, throw a SchemaValidationTopiaException. - * @param hibernateException FIXME + * + * @param hibernateException the incoming exception to test and wrap if necessary */ public static void throwIfHibernateExceptionIsAboutSchemaValidation(HibernateException hibernateException) { // XXX brendan 06/05/15 dirty hack to know if e is about schema validation since Hibernate exception management sucks -- 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/4062 in repository topia. See https://gitlab.nuiton.org/nuiton/topia.git commit 31790ef2c9eedc5e8ecdb45687022cc77451ca72 Author: Tony CHEMIT <chemit@codelutin.com> Date: Thu Dec 15 11:32:49 2016 +0100 refs #4062 Fix two tests --- .../java/org/nuiton/topia/it/legacy/persistence/NaturalIdTest.java | 7 +++---- .../java/org/nuiton/topia/migration/TopiaMigrationEngineTest.java | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/topia-it/src/test/java/org/nuiton/topia/it/legacy/persistence/NaturalIdTest.java b/topia-it/src/test/java/org/nuiton/topia/it/legacy/persistence/NaturalIdTest.java index 6a90910..5edb1e5 100644 --- a/topia-it/src/test/java/org/nuiton/topia/it/legacy/persistence/NaturalIdTest.java +++ b/topia-it/src/test/java/org/nuiton/topia/it/legacy/persistence/NaturalIdTest.java @@ -26,18 +26,17 @@ package org.nuiton.topia.it.legacy.persistence; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.hibernate.HibernateException; import org.hibernate.PropertyValueException; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.nuiton.topia.it.legacy.TopiaItLegacyDatabase; -import org.nuiton.topia.persistence.TopiaException; import org.nuiton.topia.it.legacy.TopiaItLegacyEntityEnum; import org.nuiton.topia.it.legacy.TopiaItLegacyTopiaPersistenceContext; import org.nuiton.topia.it.legacy.topiatest.NaturalizedEntity; import org.nuiton.topia.it.legacy.topiatest.NaturalizedEntityTopiaDao; - -import javax.persistence.PersistenceException; +import org.nuiton.topia.persistence.TopiaException; /** * NaturalIdTest @@ -117,7 +116,7 @@ public class NaturalIdTest { entity.setNaturalIdNotNull(8); persistenceContext.commit(); } catch (TopiaException eee) { - Assert.assertEquals(PersistenceException.class, eee.getCause().getClass()); + Assert.assertEquals(HibernateException.class, eee.getCause().getClass()); } } diff --git a/topia-service-migration/src/test/java/org/nuiton/topia/migration/TopiaMigrationEngineTest.java b/topia-service-migration/src/test/java/org/nuiton/topia/migration/TopiaMigrationEngineTest.java index 6ef173f..0f3276b 100644 --- a/topia-service-migration/src/test/java/org/nuiton/topia/migration/TopiaMigrationEngineTest.java +++ b/topia-service-migration/src/test/java/org/nuiton/topia/migration/TopiaMigrationEngineTest.java @@ -153,7 +153,7 @@ public class TopiaMigrationEngineTest { persistenceContext.close(); Assert.fail("Validation should have failed"); } catch (SchemaValidationTopiaException e) { - Assert.assertEquals("Missing column: name in H2.PUBLIC.B71", e.getMessage()); + Assert.assertEquals("Schema-validation: missing column [name] in table [b71]", e.getMessage()); } applicationContext.close(); -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm