CCM NG: Changes for Hibernate 5

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4065 8810af33-2d31-482b-a856-94f89814c4df
pull/2/head
jensp 2016-05-11 16:47:19 +00:00
parent 394fa73b85
commit 89c003b321
4 changed files with 70 additions and 36 deletions

View File

@ -48,7 +48,7 @@
<dependency> <dependency>
<groupId>org.hibernate</groupId> <groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId> <artifactId>hibernate-envers</artifactId>
<!--<scope>provided</scope>--> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -23,10 +23,10 @@ import org.apache.logging.log4j.Logger;
import org.flywaydb.core.Flyway; import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.MigrationInfo; import org.flywaydb.core.api.MigrationInfo;
import org.flywaydb.core.internal.util.jdbc.JdbcUtils; import org.flywaydb.core.internal.util.jdbc.JdbcUtils;
import org.hibernate.boot.Metadata;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.integrator.spi.Integrator; import org.hibernate.integrator.spi.Integrator;
import org.hibernate.metamodel.source.MetadataImplementor;
import org.hibernate.service.spi.SessionFactoryServiceRegistry; import org.hibernate.service.spi.SessionFactoryServiceRegistry;
import java.sql.Connection; import java.sql.Connection;
@ -67,15 +67,14 @@ public class CcmIntegrator implements Integrator {
* Checks for new and updated modules when the persistence unit is started. * Checks for new and updated modules when the persistence unit is started.
* If there are updates the necessary database migrations are executed. * If there are updates the necessary database migrations are executed.
* *
* @param configuration * @param metadata
* @param sessionFactory * @param sessionFactory
* @param registry * @param registry
*/ */
@Override @Override
public void integrate(final Configuration configuration, public void integrate(final Metadata metadata,
final SessionFactoryImplementor sessionFactory, final SessionFactoryImplementor sessionFactory,
final SessionFactoryServiceRegistry registry) { final SessionFactoryServiceRegistry registry) {
//Find all modules in the classpath
LOGGER.info("Retrieving modules..."); LOGGER.info("Retrieving modules...");
modules = ServiceLoader.load(CcmModule.class); modules = ServiceLoader.load(CcmModule.class);
for (final CcmModule module : modules) { for (final CcmModule module : modules) {
@ -117,9 +116,6 @@ public class CcmIntegrator implements Integrator {
// } // }
} }
//Build Hibernate mappings for the entities.
configuration.buildMappings();
} catch (DependencyException | SQLException ex) { } catch (DependencyException | SQLException ex) {
throw new IntegrationException("Failed to integrate modules", ex); throw new IntegrationException("Failed to integrate modules", ex);
} finally { } finally {
@ -298,13 +294,6 @@ public class CcmIntegrator implements Integrator {
} }
} }
@Override
public void integrate(final MetadataImplementor metadata,
final SessionFactoryImplementor sessionFactory,
final SessionFactoryServiceRegistry registry) {
//Nothing
}
/** /**
* Called when the application is shutdown. Used to remove the database * Called when the application is shutdown. Used to remove the database
* schema of uninstalled modules. * schema of uninstalled modules.

View File

@ -23,6 +23,11 @@ import nl.jqno.equalsverifier.Warning;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; import org.junit.runners.Parameterized;
import org.libreccm.core.CcmObject;
import org.libreccm.security.Group;
import org.libreccm.security.Permission;
import org.libreccm.security.Role;
import org.libreccm.security.User;
import org.libreccm.tests.categories.UnitTest; import org.libreccm.tests.categories.UnitTest;
import org.libreccm.web.CcmApplication; import org.libreccm.web.CcmApplication;
@ -73,6 +78,32 @@ public class EqualsAndHashCodeTest {
final CcmApplication application2 = new CcmApplication(); final CcmApplication application2 = new CcmApplication();
application2.setPrimaryUrl("http://application-two.exampl.org"); application2.setPrimaryUrl("http://application-two.exampl.org");
final CcmObject ccmObject1 = new CcmObject();
ccmObject1.setObjectId(-100);
ccmObject1.setDisplayName("Object 1");
final CcmObject ccmObject2 = new CcmObject();
ccmObject1.setObjectId(-200);
ccmObject1.setDisplayName("Object 2");
final Role role1 = new Role();
role1.setName("role1");
final Role role2 = new Role();
role2.setName("role2");
final Group group1 = new Group();
group1.setName("group1");
final Group group2 = new Group();
group2.setName("group2");
final User user1 = new TestUser();
user1.setName("user1");
final User user2 = new TestUser();
user2.setName("user2");
EqualsVerifier EqualsVerifier
.forClass(entityClass) .forClass(entityClass)
.suppress(Warning.STRICT_INHERITANCE) .suppress(Warning.STRICT_INHERITANCE)
@ -81,7 +112,21 @@ public class EqualsAndHashCodeTest {
.withPrefabValues(Category.class, category1, category2) .withPrefabValues(Category.class, category1, category2)
.withPrefabValues(Domain.class, domain1, domain2) .withPrefabValues(Domain.class, domain1, domain2)
.withPrefabValues(CcmApplication.class, application1, application2) .withPrefabValues(CcmApplication.class, application1, application2)
.withPrefabValues(CcmObject.class, ccmObject1, ccmObject2)
.withPrefabValues(Role.class, role1, role2)
.withPrefabValues(Group.class, group1, group2)
.withPrefabValues(User.class, user1, user2)
.verify(); .verify();
} }
private class TestUser extends User {
private static final long serialVersionUID = -9052762220990453621L;
protected TestUser() {
super();
}
}
} }

42
pom.xml
View File

@ -33,7 +33,7 @@
<licenses> <licenses>
<license> <license>
<name>LPLv2 or newer</name> <name>LGPLv2 or newer</name>
<url>http://www.gnu.org/licenses/lgpl-2.0.html</url> <url>http://www.gnu.org/licenses/lgpl-2.0.html</url>
</license> </license>
</licenses> </licenses>
@ -76,7 +76,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId> <artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.8</version> <version>2.9</version>
<reportSets> <reportSets>
<reportSet> <reportSet>
<reports> <reports>
@ -98,7 +98,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version> <version>3.5.1</version>
<configuration> <configuration>
<source>1.8</source> <source>1.8</source>
<target>1.8</target> <target>1.8</target>
@ -135,7 +135,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId> <artifactId>maven-site-plugin</artifactId>
<version>3.5</version> <version>3.5.1</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
@ -192,13 +192,13 @@
</plugin> </plugin>
<plugin> <plugin>
<groupId>de.jpdigital</groupId> <groupId>de.jpdigital</groupId>
<artifactId>hibernate4-ddl-maven-plugin</artifactId> <artifactId>hibernate5-ddl-maven-plugin</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.jacoco</groupId> <groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId> <artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version> <version>0.7.6.201602180812</version>
</plugin> </plugin>
<!--<plugin> <!--<plugin>
<groupId>org.jboss.tattletale</groupId> <groupId>org.jboss.tattletale</groupId>
@ -232,7 +232,7 @@
<dependency> <dependency>
<groupId>org.hibernate</groupId> <groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId> <artifactId>hibernate-entitymanager</artifactId>
<version>4.3.11.Final</version> <version>5.0.7.Final</version>
</dependency> </dependency>
<!-- <!--
@ -242,7 +242,7 @@
<dependency> <dependency>
<groupId>org.hibernate</groupId> <groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId> <artifactId>hibernate-envers</artifactId>
<version>4.3.11.Final</version> <version>5.0.7.Final</version>
</dependency> </dependency>
<!-- <!--
@ -251,12 +251,12 @@
<dependency> <dependency>
<groupId>org.hibernate</groupId> <groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId> <artifactId>hibernate-validator</artifactId>
<version>5.2.2.Final</version> <version>5.2.3.Final</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.hibernate</groupId> <groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-cdi</artifactId> <artifactId>hibernate-validator-cdi</artifactId>
<version>5.2.2.Final</version> <version>5.2.3.Final</version>
</dependency> </dependency>
<!-- <!--
@ -265,7 +265,7 @@
<dependency> <dependency>
<groupId>org.flywaydb</groupId> <groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId> <artifactId>flyway-core</artifactId>
<version>3.2.1</version> <version>4.0</version>
</dependency> </dependency>
<!-- Shiro lib for security stuff --> <!-- Shiro lib for security stuff -->
@ -329,7 +329,7 @@
<dependency> <dependency>
<groupId>commons-cli</groupId> <groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId> <artifactId>commons-cli</artifactId>
<version>1.2</version> <version>1.3.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-codec</groupId> <groupId>commons-codec</groupId>
@ -339,7 +339,7 @@
<dependency> <dependency>
<groupId>commons-collections</groupId> <groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId> <artifactId>commons-collections</artifactId>
<version>3.2.1</version> <version>3.2.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-fileupload</groupId> <groupId>commons-fileupload</groupId>
@ -354,7 +354,7 @@
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<version>2.4</version> <version>2.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-lang</groupId> <groupId>commons-lang</groupId>
@ -376,7 +376,7 @@
<dependency> <dependency>
<groupId>net.sf.saxon</groupId> <groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId> <artifactId>Saxon-HE</artifactId>
<version>9.6.0-5</version> <version>9.7.0-4</version>
</dependency> </dependency>
<dependency> <dependency>
@ -394,13 +394,13 @@
<dependency> <dependency>
<groupId>org.jsoup</groupId> <groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId> <artifactId>jsoup</artifactId>
<version>1.8.2</version> <version>1.9.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId> <artifactId>maven-artifact</artifactId>
<version>3.3.3</version> <version>3.3.9</version>
</dependency> </dependency>
<dependency> <dependency>
@ -485,7 +485,7 @@
<dependency> <dependency>
<groupId>org.jboss.arquillian</groupId> <groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId> <artifactId>arquillian-bom</artifactId>
<version>1.1.10.Final</version> <version>1.1.11.Final</version>
<scope>import</scope> <scope>import</scope>
<type>pom</type> <type>pom</type>
</dependency> </dependency>
@ -514,7 +514,7 @@
<dependency> <dependency>
<groupId>org.jacoco</groupId> <groupId>org.jacoco</groupId>
<artifactId>org.jacoco.core</artifactId> <artifactId>org.jacoco.core</artifactId>
<version>0.7.5.201505241946</version> <version>0.7.6.201602180812</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
@ -542,14 +542,14 @@
<dependency> <dependency>
<groupId>nl.jqno.equalsverifier</groupId> <groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId> <artifactId>equalsverifier</artifactId>
<version>1.7.6</version> <version>1.7.8</version>
</dependency> </dependency>
<!-- h2 database in used to check some database related things --> <!-- h2 database in used to check some database related things -->
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>
<artifactId>h2</artifactId> <artifactId>h2</artifactId>
<version>1.4.190</version> <version>1.4.191</version>
</dependency> </dependency>
</dependencies> </dependencies>