r2295 - in branches/topia-2.6.x: . topia-persistence/src/main/java/org/nuiton/topia/framework topia-persistence/src/main/java/org/nuiton/topia/generator topia-persistence/src/main/resources/i18n topia-persistence/src/test/java/org/nuiton/topia/framework topia-persistence/src/test/java/org/nuiton/topiatest/persistence topia-service-migration/src/main/java/org/nuiton/topia/migration topia-service-migration/src/main/resources/org/nuiton/topia/migration/mappings
Author: tchemit Date: 2011-05-27 09:24:56 +0200 (Fri, 27 May 2011) New Revision: 2295 Url: http://nuiton.org/repositories/revision/topia/2295 Log: Evolution #1553: Updates to h2 1.3.154 Evolution #1554: Updates to sl4j 1.6.1 Anomalie #1548: topia-persistence does not build (some test are failing) when using hibernate 3.5.6 Evolution #476: Updates to hibernate 3.6.4.Final Modified: branches/topia-2.6.x/pom.xml branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java branches/topia-2.6.x/topia-persistence/src/main/resources/i18n/topia-persistence_en_GB.properties branches/topia-2.6.x/topia-persistence/src/main/resources/i18n/topia-persistence_es_ES.properties branches/topia-2.6.x/topia-persistence/src/main/resources/i18n/topia-persistence_fr_FR.properties branches/topia-2.6.x/topia-persistence/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java branches/topia-2.6.x/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/Entity1Impl.hbm.xml branches/topia-2.6.x/topia-service-migration/src/main/java/org/nuiton/topia/migration/TopiaMigrationEngine.java branches/topia-2.6.x/topia-service-migration/src/main/resources/org/nuiton/topia/migration/mappings/TMSVersion.hbm.xml Modified: branches/topia-2.6.x/pom.xml =================================================================== --- branches/topia-2.6.x/pom.xml 2011-05-26 18:06:07 UTC (rev 2294) +++ branches/topia-2.6.x/pom.xml 2011-05-27 07:24:56 UTC (rev 2295) @@ -82,6 +82,12 @@ <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>${hibernateVersion}</version> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </exclusion> + </exclusions> <scope>compile</scope> </dependency> @@ -110,8 +116,14 @@ --> <dependency> <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>${sl4jVersion}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> - <version>1.6.1</version> + <version>${sl4jVersion}</version> <scope>test</scope> </dependency> @@ -119,7 +131,7 @@ <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> - <version>1.2.128</version> + <version>1.3.154</version> <scope>test</scope> </dependency> @@ -261,7 +273,9 @@ <processorPluginVersion>1.2.1</processorPluginVersion> <nuitonI18nVersion>2.4</nuitonI18nVersion> <xmlrpcVersion>3.1.2</xmlrpcVersion> - <hibernateVersion>3.3.2.GA</hibernateVersion> + <!--<hibernateVersion>3.3.2.GA</hibernateVersion>--> + <hibernateVersion>3.6.4.Final</hibernateVersion> + <sl4jVersion>1.6.1</sl4jVersion> <!-- i18n configuration --> <i18n.bundles>fr_FR,en_GB,es_ES</i18n.bundles> Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java =================================================================== --- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java 2011-05-26 18:06:07 UTC (rev 2294) +++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java 2011-05-27 07:24:56 UTC (rev 2295) @@ -607,7 +607,7 @@ // ajout des repertoires contenant les mappings hibernate String[] dirs = getConfig().getProperty( - TOPIA_PERSISTENCE_DIRECTORIES, "").split(","); + TopiaContextFactory.CONFIG_PERSISTENCE_DIRECTORIES, "").split(","); for (String dir : dirs) { dir = dir.trim(); if (StringUtils.isNotEmpty(dir)) { @@ -634,7 +634,7 @@ } String listPersistenceClasses = getConfig().getProperty( - TOPIA_PERSISTENCE_CLASSES, ""); + TopiaContextFactory.CONFIG_PERSISTENCE_CLASSES, ""); String[] classes = listPersistenceClasses.split(","); for (String classname : classes) { @@ -677,7 +677,7 @@ // TOPIA_PERSISTENCE_PROPERTIES_FILE in config. Properties propertiesFromClasspath = TopiaUtil.getProperties(getConfig(). - getProperty(TOPIA_PERSISTENCE_PROPERTIES_FILE)); + getProperty(TopiaContextFactory.CONFIG_PERSISTENCE_PROPERTIES_FILE)); if (!propertiesFromClasspath.isEmpty()) { if (log.isDebugEnabled()) { @@ -688,6 +688,9 @@ } hibernateConfiguration.setProperties(prop); + + // 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; @@ -1212,8 +1215,7 @@ } } } catch (HibernateException eee) { - throw new TopiaException(_( - "topia.persistence.error.on.replicate", + throw new TopiaException(_("topia.persistence.error.on.replicate", eee.getMessage()), eee); } } @@ -1572,8 +1574,7 @@ } } catch (HibernateException eee) { - throw new TopiaException(_( - "topia.persistence.error.on.replicate", + throw new TopiaException(_("topia.persistence.error.on.replicate", eee.getMessage()), eee); } } Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java =================================================================== --- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java 2011-05-26 18:06:07 UTC (rev 2294) +++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java 2011-05-27 07:24:56 UTC (rev 2295) @@ -42,16 +42,16 @@ package org.nuiton.topia.generator; +import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.nuiton.eugene.GeneratorUtil; import org.nuiton.eugene.java.JavaGeneratorUtil; -import org.nuiton.eugene.models.object.ObjectModelGenerator; -import org.nuiton.eugene.GeneratorUtil; import org.nuiton.eugene.models.object.ObjectModelAssociationClass; import org.nuiton.eugene.models.object.ObjectModelAttribute; import org.nuiton.eugene.models.object.ObjectModelClass; -import static org.nuiton.topia.generator.TopiaGeneratorUtil.hasUnidirectionalRelationOnAbstractType; +import org.nuiton.eugene.models.object.ObjectModelGenerator; import java.io.File; import java.io.IOException; @@ -62,7 +62,7 @@ import java.util.Map; import java.util.TreeMap; -import org.apache.commons.lang.BooleanUtils; +import static org.nuiton.topia.generator.TopiaGeneratorUtil.hasUnidirectionalRelationOnAbstractType; /** * FIXME-poussin-20060102 mettre les attributs node="..." sur tous les attributs @@ -118,7 +118,8 @@ return; } /*{<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> +<!--DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"--> <hibernate-mapping default-access="field" auto-import="true" package="<%=input.getPackageName()%>"> }*/ boolean haveSuper = input.getSuperclasses().size() > 0; Modified: branches/topia-2.6.x/topia-persistence/src/main/resources/i18n/topia-persistence_en_GB.properties =================================================================== --- branches/topia-2.6.x/topia-persistence/src/main/resources/i18n/topia-persistence_en_GB.properties 2011-05-26 18:06:07 UTC (rev 2294) +++ branches/topia-2.6.x/topia-persistence/src/main/resources/i18n/topia-persistence_en_GB.properties 2011-05-27 07:24:56 UTC (rev 2295) @@ -9,6 +9,7 @@ topia.persistence.error.on.export=An error occurs while export operation \: %1$s topia.persistence.error.on.loding.xml.doc=Could not read xml document for following reason \: %1$s topia.persistence.error.on.query=An error occurs while query operation \: %1$s +topia.persistence.error.on.replicate=An error occurs while a replication operation \: %s topia.persistence.error.on.rollback=An error occurs while rollback operation \: %1$s topia.persistence.error.open.transaction.failed=An error occurs while asking a new transaction \: %1$s topia.persistence.error.replicate.entity=Could not replicate entity '%1$s' pour following reason \: %2$s Modified: branches/topia-2.6.x/topia-persistence/src/main/resources/i18n/topia-persistence_es_ES.properties =================================================================== --- branches/topia-2.6.x/topia-persistence/src/main/resources/i18n/topia-persistence_es_ES.properties 2011-05-26 18:06:07 UTC (rev 2294) +++ branches/topia-2.6.x/topia-persistence/src/main/resources/i18n/topia-persistence_es_ES.properties 2011-05-27 07:24:56 UTC (rev 2295) @@ -9,6 +9,7 @@ topia.persistence.error.on.export=Se produjo un error durante la exportación \: %1$s topia.persistence.error.on.loding.xml.doc=No se puede leer el documento debido a \: %1$s topia.persistence.error.on.query=Se produjo un error duratne la busqueda (consulta %1$s) \: %2$s +topia.persistence.error.on.replicate=Se produjo un error durante la vuelta a atrás (replication) \: %1$s topia.persistence.error.on.rollback=Se produjo un error durante la vuelta a atrás (rollback) \: %1$s topia.persistence.error.open.transaction.failed= topia.persistence.error.replicate.entity=Error de repliación de la entidad %1$s\ndebido a la siguiente razón \: %2$s Modified: branches/topia-2.6.x/topia-persistence/src/main/resources/i18n/topia-persistence_fr_FR.properties =================================================================== --- branches/topia-2.6.x/topia-persistence/src/main/resources/i18n/topia-persistence_fr_FR.properties 2011-05-26 18:06:07 UTC (rev 2294) +++ branches/topia-2.6.x/topia-persistence/src/main/resources/i18n/topia-persistence_fr_FR.properties 2011-05-27 07:24:56 UTC (rev 2295) @@ -9,6 +9,7 @@ topia.persistence.error.on.export=Une erreur est apparue pendant l'export \: %1$s topia.persistence.error.on.loding.xml.doc=Lecture du document impossible pour la raison suivante \: %1$s topia.persistence.error.on.query=Une erreur est apparue pendant le recherche (requête %1$s) \: %2$s +topia.persistence.error.on.replicate=Une erreur lors de la réplication est survenue \: %s topia.persistence.error.on.rollback=Une erreur est apparue pendant le rollback \: %1$s topia.persistence.error.open.transaction.failed=Une erreur est apparue pendant la demande de transaction \: %1$s topia.persistence.error.replicate.entity=Echec de replication de l'entite %1$s\npour la raison suivante \: %2$s Modified: branches/topia-2.6.x/topia-persistence/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java =================================================================== --- branches/topia-2.6.x/topia-persistence/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java 2011-05-26 18:06:07 UTC (rev 2294) +++ branches/topia-2.6.x/topia-persistence/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java 2011-05-27 07:24:56 UTC (rev 2295) @@ -130,28 +130,40 @@ TopiaContextImpl child = new TopiaContextImpl(context); /** EXEC METHOD **/ - log.info("test 1 : with child context"); + if (log.isInfoEnabled()) { + log.info("test 1 : with child context"); + } Map<String, TopiaService> test1 = child.getServices(); Assert.assertEquals(1, test1.size()); Assert.assertTrue(test1.containsKey("test")); - log.info("test 2 : test serviceEnabled method"); + if (log.isInfoEnabled()) { + log.info("test 2 : test serviceEnabled method"); + } boolean test2 = child.serviceEnabled("test"); Assert.assertTrue(test2); - log.info("test 3 : test getService method"); + if (log.isInfoEnabled()) { + log.info("test 3 : test getService method"); + } TopiaService test3 = child.getService("test"); Assert.assertEquals(TestService.class, test3.getClass()); - log.info("test 4 : test serviceEnabled from class TestService"); + if (log.isInfoEnabled()) { + log.info("test 4 : test serviceEnabled from class TestService"); + } boolean test4 = child.serviceEnabled(TestService.class); Assert.assertTrue(test4); - log.info("test 5 : test getService from class TestService"); + if (log.isInfoEnabled()) { + log.info("test 5 : test getService from class TestService"); + } TestService test5 = child.getService(TestService.class); Assert.assertNotNull(test5); - log.info("test 6 : test serviceEnabled error with class FakeService"); + if (log.isInfoEnabled()) { + log.info("test 6 : test serviceEnabled error with class FakeService"); + } // FakeService doesn't contains property SERVICE_NAME used by // serviceEnabled method // Even it's properly loaded the serviceEnabled method will return false @@ -163,14 +175,19 @@ boolean test6 = otherContext.serviceEnabled(FakeService.class); Assert.assertFalse(test6); - log.info("test 7 : test getService with error TopiaNotFoundException" + - " : service not loaded"); + if (log.isInfoEnabled()) { + log.info("test 7 : test getService with error TopiaNotFoundException" + + " : service not loaded"); + } // TestService is not loaded in otherContext try { TestService test7 = otherContext.getService(TestService.class); - } catch (Exception eee) { - log.error(eee.getClass().getSimpleName() + " : " + eee.getMessage()); - Assert.assertEquals(TopiaNotFoundException.class, eee.getClass()); + Assert.fail(); + } catch (TopiaNotFoundException eee) { + //log.error(eee.getClass().getSimpleName() + " : " + eee.getMessage()); + //Assert.assertEquals(TopiaNotFoundException.class, eee.getClass()); + } catch (Exception e) { + Assert.fail(); } } @@ -182,17 +199,23 @@ TopiaContextImpl context = new TopiaContextImpl(properties); /** EXEC METHODS **/ - log.info("test 1 : constructor with parent context"); + if (log.isInfoEnabled()) { + log.info("test 1 : constructor with parent context"); + } TopiaContextImpl test1 = new TopiaContextImpl(context); Assert.assertEquals(context, test1.parentContext); - log.info("test 2 : addChildContext"); + if (log.isInfoEnabled()) { + log.info("test 2 : addChildContext"); + } TopiaContextImpl test2 = new TopiaContextImpl(properties); TopiaContextImpl child2 = new TopiaContextImpl(); test2.addChildContext(child2); Assert.assertEquals(1, test2.childContext.size()); - log.info("test 3 : removeChildContext"); + if (log.isInfoEnabled()) { + log.info("test 3 : removeChildContext"); + } TopiaContextImpl test3 = new TopiaContextImpl(properties); TopiaContextImpl child3 = new TopiaContextImpl(test3); test3.childContext.add(child3); @@ -205,7 +228,9 @@ test3.removeChildContext(child3); Assert.assertEquals(1, test3.childContext.size()); - log.info("test 4 : getRootContext"); + if (log.isInfoEnabled()) { + log.info("test 4 : getRootContext"); + } TopiaContextImplementor test4 = child3.getRootContext(); Assert.assertEquals(test3, test4); @@ -232,7 +257,9 @@ @Test public void testGetHibernateFactory() throws Exception { - log.info("## testGetHibernateFactory"); + if (log.isInfoEnabled()) { + log.info("## testGetHibernateFactory"); + } /** PREPARE DATA **/ TopiaContextImpl context = new TopiaContextImpl(); @@ -245,7 +272,9 @@ basedir = new File("").getAbsolutePath(); } - log.debug("baseDir : " + basedir); + if (log.isDebugEnabled()) { + log.debug("baseDir : " + basedir); + } File persistenceDir = new File(basedir, "target" + File.separator + "test-classes" +File.separator + @@ -253,14 +282,21 @@ "nuiton" + File.separator + "topiatest" + File.separator + "persistence"); - log.debug("persistenceDir : " + persistenceDir); + if (log.isDebugEnabled()) { + log.debug("persistenceDir : " + persistenceDir); + } File resourcesDir = new File(basedir, "target" + File.separator + "test-classes"); /** EXEC METHOD **/ - log.info("test 1 : load mappings from directory"); - + if (log.isInfoEnabled()) { + log.info("test 1 : load mappings from directory"); + } + +// properties.setProperty(TopiaContextFactory.CONFIG_PERSISTENCE_CLASSES, +// Entity1Impl.class.getName()); + properties.setProperty(TopiaContextFactory.CONFIG_PERSISTENCE_DIRECTORIES, persistenceDir.getAbsolutePath()); context.config = properties; @@ -276,7 +312,9 @@ // log.debug("entity : " + o.getEntityName()); // } - log.info("test 2 : load mappings for all entities"); + if (log.isInfoEnabled()) { + log.info("test 2 : load mappings for all entities"); + } //reset from previous test context = new TopiaContextImpl(); context.services = new HashMap<String, TopiaService>(); @@ -292,7 +330,9 @@ Assert.assertNotNull(persistentClass); Assert.assertEquals(Entity1.class, persistentClass.getProxyInterface()); - log.info("test 3 : add properties from file"); + if (log.isInfoEnabled()) { + log.info("test 3 : add properties from file"); + } //reset from previous test context = new TopiaContextImpl(); context.services = new HashMap<String, TopiaService>(); Modified: branches/topia-2.6.x/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/Entity1Impl.hbm.xml =================================================================== --- branches/topia-2.6.x/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/Entity1Impl.hbm.xml 2011-05-26 18:06:07 UTC (rev 2294) +++ branches/topia-2.6.x/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/Entity1Impl.hbm.xml 2011-05-27 07:24:56 UTC (rev 2295) @@ -24,7 +24,8 @@ #L% --> -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<!--<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">--> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping default-access="field" auto-import="true" package="org.nuiton.topiatest"> <class name="org.nuiton.topiatest.persistence.Entity1Impl" table="entity1" node="org.nuiton.topiatest.persistence.Entity1Impl" abstract="false" proxy="org.nuiton.topiatest.persistence.Entity1" > <id name="topiaId" type="string" length="255" node="@topiaId"/> Modified: branches/topia-2.6.x/topia-service-migration/src/main/java/org/nuiton/topia/migration/TopiaMigrationEngine.java =================================================================== --- branches/topia-2.6.x/topia-service-migration/src/main/java/org/nuiton/topia/migration/TopiaMigrationEngine.java 2011-05-26 18:06:07 UTC (rev 2294) +++ branches/topia-2.6.x/topia-service-migration/src/main/java/org/nuiton/topia/migration/TopiaMigrationEngine.java 2011-05-27 07:24:56 UTC (rev 2295) @@ -687,6 +687,7 @@ prop.putAll(config); configuration.setProperties(prop); + configuration.buildMappings(); return configuration; } Modified: branches/topia-2.6.x/topia-service-migration/src/main/resources/org/nuiton/topia/migration/mappings/TMSVersion.hbm.xml =================================================================== --- branches/topia-2.6.x/topia-service-migration/src/main/resources/org/nuiton/topia/migration/mappings/TMSVersion.hbm.xml 2011-05-26 18:06:07 UTC (rev 2294) +++ branches/topia-2.6.x/topia-service-migration/src/main/resources/org/nuiton/topia/migration/mappings/TMSVersion.hbm.xml 2011-05-27 07:24:56 UTC (rev 2295) @@ -24,7 +24,8 @@ #L% --> -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<!--<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">--> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="org.nuiton.topia.migration.mappings.TMSVersion" table="tms_version"> <id column="version" name="version"/>
participants (1)
-
tchemit@users.nuiton.org