DATAJPA-1085 - Upgraded Hibernate baseline to 5.2.
Removed build profiles for older Hibernate versions, Travis build setup for those. Removed reflection based code paths to support older versions of Hibernate. Removed build profiles for Spring 5 and 4.3 as well.
This commit is contained in:
@@ -6,15 +6,7 @@ jdk:
|
||||
env:
|
||||
matrix:
|
||||
- PROFILE=ci
|
||||
- PROFILE=spring43
|
||||
- PROFILE=spring43-next
|
||||
- PROFILE=spring5
|
||||
- PROFILE=spring5-next
|
||||
- PROFILE=hibernate-43-next
|
||||
- PROFILE=hibernate-5
|
||||
- PROFILE=hibernate-51
|
||||
- PROFILE=hibernate-51-next
|
||||
- PROFILE=hibernate-52
|
||||
- PROFILE=hibernate-52-next
|
||||
- PROFILE=eclipselink-next
|
||||
- PROFILE=eclipselink-27-next
|
||||
|
||||
63
pom.xml
63
pom.xml
@@ -22,8 +22,7 @@
|
||||
<dist.key>DATAJPA</dist.key>
|
||||
|
||||
<eclipselink>2.6.2</eclipselink>
|
||||
<hibernate>4.3.11.Final</hibernate>
|
||||
<hibernate.artifact>hibernate-entitymanager</hibernate.artifact>
|
||||
<hibernate>5.2.9.Final</hibernate>
|
||||
<hsqldb1>1.8.0.10</hsqldb1>
|
||||
<jpa>2.0.0</jpa>
|
||||
<openjpa>2.4.1</openjpa>
|
||||
@@ -34,66 +33,10 @@
|
||||
</properties>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>hibernate-43-next</id>
|
||||
<properties>
|
||||
<hibernate>4.3.12-SNAPSHOT</hibernate>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jboss</id>
|
||||
<url>https://repository.jboss.org/nexus/content/repositories/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>hibernate-5</id>
|
||||
<properties>
|
||||
<hibernate>5.0.10.Final</hibernate>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>hibernate-5-next</id>
|
||||
<properties>
|
||||
<hibernate>5.0.11-SNAPSHOTS</hibernate>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jboss</id>
|
||||
<url>https://repository.jboss.org/nexus/content/repositories/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>hibernate-51</id>
|
||||
<properties>
|
||||
<hibernate>5.1.1.Final</hibernate>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>hibernate-51-next</id>
|
||||
<properties>
|
||||
<hibernate>5.1.2-SNAPSHOT</hibernate>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jboss</id>
|
||||
<url>https://repository.jboss.org/nexus/content/repositories/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>hibernate-52</id>
|
||||
<properties>
|
||||
<hibernate>5.2.7.Final</hibernate>
|
||||
<hibernate.artifact>hibernate-core</hibernate.artifact>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>hibernate-52-next</id>
|
||||
<properties>
|
||||
<hibernate>5.2.8-SNAPSHOT</hibernate>
|
||||
<hibernate.artifact>hibernate-core</hibernate.artifact>
|
||||
<hibernate>5.2.10-SNAPSHOT</hibernate>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
@@ -241,7 +184,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>${hibernate.artifact}</artifactId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<version>${hibernate}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.data.jpa.provider;
|
||||
import static org.springframework.data.jpa.provider.JpaClassUtils.*;
|
||||
import static org.springframework.data.jpa.provider.PersistenceProvider.Constants.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -44,9 +43,7 @@ import org.hibernate.proxy.HibernateProxy;
|
||||
import org.springframework.data.util.CloseableIterator;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* Enumeration representing persistence providers to be used.
|
||||
@@ -65,9 +62,8 @@ public enum PersistenceProvider implements QueryExtractor, ProxyIdAccessor {
|
||||
* @see <a href="https://jira.spring.io/browse/DATAJPA-444">DATAJPA-444</a>
|
||||
*/
|
||||
HIBERNATE(//
|
||||
Arrays.asList(HIBERNATE52_ENTITY_MANAGER_INTERFACE, HIBERNATE43_ENTITY_MANAGER_INTERFACE,
|
||||
HIBERNATE_ENTITY_MANAGER_INTERFACE), //
|
||||
Arrays.asList(HIBERNATE52_JPA_METAMODEL_TYPE, HIBERNATE43_JPA_METAMODEL_TYPE, HIBERNATE_JPA_METAMODEL_TYPE)) {
|
||||
Arrays.asList(HIBERNATE_ENTITY_MANAGER_INTERFACE), //
|
||||
Arrays.asList(HIBERNATE_JPA_METAMODEL_TYPE)) {
|
||||
|
||||
public String extractQueryString(Query query) {
|
||||
return HibernateUtils.getHibernateQuery(query);
|
||||
@@ -261,13 +257,11 @@ public enum PersistenceProvider implements QueryExtractor, ProxyIdAccessor {
|
||||
String GENERIC_JPA_ENTITY_MANAGER_INTERFACE = "javax.persistence.EntityManager";
|
||||
String OPENJPA_ENTITY_MANAGER_INTERFACE = "org.apache.openjpa.persistence.OpenJPAEntityManager";
|
||||
String ECLIPSELINK_ENTITY_MANAGER_INTERFACE = "org.eclipse.persistence.jpa.JpaEntityManager";
|
||||
String HIBERNATE_ENTITY_MANAGER_INTERFACE = "org.hibernate.ejb.HibernateEntityManager";
|
||||
String HIBERNATE43_ENTITY_MANAGER_INTERFACE = "org.hibernate.jpa.HibernateEntityManager";
|
||||
String HIBERNATE52_ENTITY_MANAGER_INTERFACE = "org.hibernate.Session";
|
||||
String HIBERNATE_SESSION_INTERFACE = "org.hibernate.Session";
|
||||
// needed as Spring only exposes that interface via the EM proxy
|
||||
String HIBERNATE_ENTITY_MANAGER_INTERFACE = "org.hibernate.jpa.HibernateEntityManager";
|
||||
|
||||
String HIBERNATE_JPA_METAMODEL_TYPE = "org.hibernate.ejb.metamodel.MetamodelImpl";
|
||||
String HIBERNATE43_JPA_METAMODEL_TYPE = "org.hibernate.jpa.internal.metamodel.MetamodelImpl";
|
||||
String HIBERNATE52_JPA_METAMODEL_TYPE = "org.hibernate.metamodel.internal.MetamodelImpl";
|
||||
String HIBERNATE_JPA_METAMODEL_TYPE = "org.hibernate.metamodel.internal.MetamodelImpl";
|
||||
String ECLIPSELINK_JPA_METAMODEL_TYPE = "org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl";
|
||||
String OPENJPA_JPA_METAMODEL_TYPE = "org.apache.openjpa.persistence.meta.MetamodelImpl";
|
||||
}
|
||||
@@ -406,11 +400,6 @@ public enum PersistenceProvider implements QueryExtractor, ProxyIdAccessor {
|
||||
*/
|
||||
private static class HibernateScrollableResultsIterator implements CloseableIterator<Object> {
|
||||
|
||||
private static final Method READ_ONLY_METHOD = ClassUtils.getMethod(org.hibernate.Query.class, "setReadOnly",
|
||||
boolean.class);
|
||||
private static final Method SCROLL_METHOD = ClassUtils.getMethod(READ_ONLY_METHOD.getReturnType(), "scroll",
|
||||
ScrollMode.class);
|
||||
|
||||
private final ScrollableResults scrollableResults;
|
||||
|
||||
/**
|
||||
@@ -420,19 +409,9 @@ public enum PersistenceProvider implements QueryExtractor, ProxyIdAccessor {
|
||||
*/
|
||||
public HibernateScrollableResultsIterator(Query jpaQuery) {
|
||||
|
||||
org.hibernate.Query query = jpaQuery.unwrap(org.hibernate.Query.class);
|
||||
boolean isReadOnly = TransactionSynchronizationManager.isCurrentTransactionReadOnly();
|
||||
|
||||
if (READ_ONLY_METHOD.getReturnType().equals(org.hibernate.Query.class)) {
|
||||
|
||||
this.scrollableResults = query.setReadOnly(isReadOnly).scroll(ScrollMode.FORWARD_ONLY);
|
||||
|
||||
} else {
|
||||
|
||||
Object intermediate = ReflectionUtils.invokeMethod(READ_ONLY_METHOD, jpaQuery, isReadOnly);
|
||||
this.scrollableResults = (ScrollableResults) ReflectionUtils.invokeMethod(SCROLL_METHOD, intermediate,
|
||||
ScrollMode.FORWARD_ONLY);
|
||||
}
|
||||
org.hibernate.query.Query<?> query = jpaQuery.unwrap(org.hibernate.query.Query.class);
|
||||
this.scrollableResults = query.setReadOnly(TransactionSynchronizationManager.isCurrentTransactionReadOnly())//
|
||||
.scroll(ScrollMode.FORWARD_ONLY);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -50,26 +50,6 @@ public class PersistenceProviderUnitTests {
|
||||
this.shadowingClassLoader = new ShadowingClassLoader(getClass().getClassLoader());
|
||||
}
|
||||
|
||||
@Test // DATAJPA-444
|
||||
public void detectsHibernatePersistenceProviderForHibernateVersionLessThan4Dot3() throws Exception {
|
||||
|
||||
shadowingClassLoader.excludePackage("org.hibernate");
|
||||
|
||||
EntityManager em = mockProviderSpecificEntityManagerInterface(HIBERNATE_ENTITY_MANAGER_INTERFACE);
|
||||
|
||||
assertThat(fromEntityManager(em), is(HIBERNATE));
|
||||
}
|
||||
|
||||
@Test // DATAJPA-444
|
||||
public void detectsHibernatePersistenceProviderForHibernateVersionGreaterEqual4dot3() throws Exception {
|
||||
|
||||
shadowingClassLoader.excludePackage("org.hibernate");
|
||||
|
||||
EntityManager em = mockProviderSpecificEntityManagerInterface(HIBERNATE43_ENTITY_MANAGER_INTERFACE);
|
||||
|
||||
assertThat(fromEntityManager(em), is(HIBERNATE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void detectsOpenJpaPersistenceProvider() throws Exception {
|
||||
|
||||
@@ -105,7 +85,7 @@ public class PersistenceProviderUnitTests {
|
||||
|
||||
shadowingClassLoader.excludePackage("org.hibernate");
|
||||
|
||||
EntityManager em = mockProviderSpecificEntityManagerInterface(HIBERNATE52_ENTITY_MANAGER_INTERFACE);
|
||||
EntityManager em = mockProviderSpecificEntityManagerInterface(HIBERNATE_ENTITY_MANAGER_INTERFACE);
|
||||
|
||||
assertThat(fromEntityManager(em), is(HIBERNATE));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user