Upgrade to JPA 2.1+ and Bean Validation 1.1+; remove native support for Hibernate 3.6 and 4.x

Issue: SPR-13481
Issue: SPR-13827
This commit is contained in:
Juergen Hoeller
2016-07-04 23:37:23 +02:00
parent 69ec437fbc
commit 54004e0d78
128 changed files with 299 additions and 26731 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
package org.springframework.test.context.junit4.orm;
import javax.persistence.PersistenceException;
import org.hibernate.SessionFactory;
import org.hibernate.exception.ConstraintViolationException;
import org.junit.Before;
@@ -107,10 +109,16 @@ public class HibernateSessionFlushingTests extends AbstractTransactionalJUnit4Sp
}
@Test(expected = ConstraintViolationException.class)
public void updateSamWithNullDriversLicenseWithSessionFlush() {
public void updateSamWithNullDriversLicenseWithSessionFlush() throws Throwable {
updateSamWithNullDriversLicense();
// Manual flush is required to avoid false positive in test
sessionFactory.getCurrentSession().flush();
try {
sessionFactory.getCurrentSession().flush();
}
catch (PersistenceException ex) {
// Wrapped in Hibernate 5.2, with the constraint violation as cause
throw ex.getCause();
}
}
}

View File

@@ -8,17 +8,17 @@
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">
<context:component-scan base-package="org.springframework.test.context.junit4.orm" />
<context:component-scan base-package="org.springframework.test.context.junit4.orm"/>
<tx:annotation-driven />
<jdbc:embedded-database id="dataSource" type="HSQL">
<jdbc:script location="classpath:/org/springframework/test/context/junit4/orm/db-schema.sql" />
<jdbc:script location="classpath:/org/springframework/test/context/junit4/orm/db-test-data.sql" />
<jdbc:script location="classpath:/org/springframework/test/context/junit4/orm/db-schema.sql"/>
<jdbc:script location="classpath:/org/springframework/test/context/junit4/orm/db-test-data.sql"/>
</jdbc:embedded-database>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"
p:dataSource-ref="dataSource">
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"
p:dataSource-ref="dataSource">
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
@@ -33,7 +33,7 @@
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"
p:sessionFactory-ref="sessionFactory" />
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager"
p:sessionFactory-ref="sessionFactory"/>
</beans>