DATAJPA-703 - Added build profile for Hibernate 5.
Disabled outdated Travis build profiles for Spring 4.0 and 4.1. Upgraded profiles for Hibernate 4.2 and 4.3 to the most recent releases. Fixed stored procedure integration test to really run on EclipseLink for the EclipseLink specific tests. Added workaround for EclipseLink using invalid syntax (see [0]). [0] https://bugs.eclipse.org/bugs/show_bug.cgi?id=467072
This commit is contained in:
@@ -6,13 +6,12 @@ jdk:
|
||||
env:
|
||||
matrix:
|
||||
- PROFILE=ci
|
||||
- PROFILE=spring4-next
|
||||
- PROFILE=spring41
|
||||
- PROFILE=spring41-next
|
||||
- PROFILE=spring42-next
|
||||
- PROFILE=hibernate-41
|
||||
- PROFILE=hibernate-42
|
||||
- PROFILE=hibernate-43
|
||||
- PROFILE=hibernate-5
|
||||
- PROFILE=querydsl-next
|
||||
|
||||
sudo: false
|
||||
|
||||
22
pom.xml
22
pom.xml
@@ -43,15 +43,33 @@
|
||||
<profile>
|
||||
<id>hibernate-42</id>
|
||||
<properties>
|
||||
<hibernate>4.2.11.Final</hibernate>
|
||||
<hibernate>4.2.19.Final</hibernate>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>hibernate-43</id>
|
||||
<properties>
|
||||
<hibernate>4.3.4.Final</hibernate>
|
||||
<hibernate>4.3.9.Final</hibernate>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>hibernate-5</id>
|
||||
<properties>
|
||||
<hibernate>5.0.0.Beta2</hibernate>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>hibernate-5-next</id>
|
||||
<properties>
|
||||
<hibernate>5.0.0-SNAPSHOT</hibernate>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jboss</id>
|
||||
<url>https://repository.jboss.org/nexus/content/repositories/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -47,12 +47,12 @@ import org.springframework.util.ObjectUtils;
|
||||
,
|
||||
@NamedStoredProcedureQuery(name = "Dummy.procedureWith1InputAnd1OutputParameterWithResultSet",
|
||||
procedureName = "procedure_in1_out0_return_rs_no_update", parameters = {
|
||||
@StoredProcedureParameter(mode = ParameterMode.IN, type = Integer.class),
|
||||
@StoredProcedureParameter(mode = ParameterMode.IN, type = String.class),
|
||||
@StoredProcedureParameter(mode = ParameterMode.REF_CURSOR, type = void.class) }) //
|
||||
,
|
||||
@NamedStoredProcedureQuery(name = "Dummy.procedureWith1InputAnd1OutputParameterWithResultSetWithUpdate",
|
||||
procedureName = "procedure_in1_out0_return_rs_with_update", parameters = {
|
||||
@StoredProcedureParameter(mode = ParameterMode.IN, type = Integer.class),
|
||||
@StoredProcedureParameter(mode = ParameterMode.IN, type = String.class),
|
||||
@StoredProcedureParameter(mode = ParameterMode.REF_CURSOR, type = void.class) }) //
|
||||
,
|
||||
@NamedStoredProcedureQuery(name = "Dummy.procedureWith1InputAndNoOutputParameterWithUpdate",
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2015 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.jpa.repository;
|
||||
|
||||
import org.eclipse.persistence.internal.databaseaccess.DatabasePlatform;
|
||||
import org.eclipse.persistence.platform.database.HSQLPlatform;
|
||||
import org.springframework.orm.jpa.vendor.Database;
|
||||
import org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter;
|
||||
|
||||
/**
|
||||
* Custom {@link EclipseLinkJpaVendorAdapter} to customize the {@link DatabasePlatform} to be sued with EclipseLink to
|
||||
* work around a bug in stored procedure execution on HSQLDB.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=467072
|
||||
*/
|
||||
public class CustomEclipseLinkJpaVendorAdapter extends EclipseLinkJpaVendorAdapter {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter#determineTargetDatabaseName(org.springframework.orm.jpa.vendor.Database)
|
||||
*/
|
||||
@Override
|
||||
protected String determineTargetDatabaseName(Database database) {
|
||||
|
||||
if (Database.HSQL.equals(database)) {
|
||||
return EclipseLinkHsqlPlatform.class.getName();
|
||||
}
|
||||
|
||||
return super.determineTargetDatabaseName(database);
|
||||
}
|
||||
|
||||
/**
|
||||
* Workaround {@link HSQLPlatform} to make sure EclipseLink uses the right syntax to call stored procedures on HSQL.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=467072
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public static class EclipseLinkHsqlPlatform extends HSQLPlatform {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.persistence.internal.databaseaccess.DatabasePlatform#getProcedureCallHeader()
|
||||
*/
|
||||
@Override
|
||||
public String getProcedureCallHeader() {
|
||||
return "CALL ";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,11 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
* Testcase to run {@link StoredProcedureIntegrationTests} integration tests on top of EclipseLink.
|
||||
*
|
||||
* @author Thomas Darimont
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@ContextConfiguration(classes = { StoredProcedureIntegrationTests.Config.class })
|
||||
@ImportResource("classpath:eclipselink.xml")
|
||||
public class EclipseLinkStoredProcedureIntegrationTests extends StoredProcedureIntegrationTests {}
|
||||
@ContextConfiguration
|
||||
public class EclipseLinkStoredProcedureIntegrationTests extends StoredProcedureIntegrationTests {
|
||||
|
||||
@ImportResource({ "classpath:infrastructure.xml", "classpath:eclipselink.xml" })
|
||||
static class TestConfig extends Config {}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,12 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
* supported since, the OpenJPA tests need to be executed with hsqldb1 which doesn't supported stored procedures.
|
||||
*
|
||||
* @author Thomas Darimont
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Ignore
|
||||
@ContextConfiguration(classes = { StoredProcedureIntegrationTests.Config.class })
|
||||
@ImportResource("classpath:openjpa.xml")
|
||||
public class OpenJpaStoredProcedureIntegrationTests extends StoredProcedureIntegrationTests {}
|
||||
public class OpenJpaStoredProcedureIntegrationTests extends StoredProcedureIntegrationTests {
|
||||
|
||||
@ImportResource({ "classpath:infrastructure.xml", "classpath:openjpa.xml" })
|
||||
static class TestConfig extends Config {}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -41,35 +42,33 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @see scripts/schema-stored-procedures.sql for procedure definitions.
|
||||
* Integration tests for
|
||||
*
|
||||
* @author Thomas Darimont
|
||||
* @author Oliver Gierke
|
||||
* @see scripts/schema-stored-procedures.sql for procedure definitions.
|
||||
*/
|
||||
@Transactional
|
||||
@ContextConfiguration
|
||||
@ContextConfiguration(classes = StoredProcedureIntegrationTests.TestConfig.class)
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class StoredProcedureIntegrationTests {
|
||||
|
||||
private static final String NOT_SUPPORTED = "Stored procedures with ResultSets are currently not supported for any JPA provider";
|
||||
|
||||
@PersistenceContext EntityManager em;
|
||||
@Autowired DummyRepository repository;
|
||||
|
||||
Dummy dummyA;
|
||||
Dummy dummyB;
|
||||
Dummy dummyC;
|
||||
|
||||
@Configuration
|
||||
@EnableJpaRepositories(basePackageClasses = DummyRepository.class, includeFilters = { @Filter(
|
||||
pattern = ".*DummyRepository", type = FilterType.REGEX) })
|
||||
static abstract class Config {}
|
||||
|
||||
@ImportResource("classpath:infrastructure.xml")
|
||||
static class Config {}
|
||||
static class TestConfig extends Config {}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
|
||||
assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
|
||||
dummyA = em.merge(new Dummy("A"));
|
||||
dummyB = em.merge(new Dummy("B"));
|
||||
dummyC = em.merge(new Dummy("C"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,7 +76,7 @@ public class StoredProcedureIntegrationTests {
|
||||
*/
|
||||
@Test
|
||||
public void shouldExecuteAdHocProcedureWithNoInputAnd1OutputParameter() {
|
||||
assertThat(repository.adHocProcedureWithNoInputAnd1OutputParameter(), is(equalTo(42)));
|
||||
assertThat(repository.adHocProcedureWithNoInputAnd1OutputParameter(), is(42));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +84,7 @@ public class StoredProcedureIntegrationTests {
|
||||
*/
|
||||
@Test
|
||||
public void shouldExecuteAdHocProcedureWith1InputAnd1OutputParameter() {
|
||||
assertThat(repository.adHocProcedureWith1InputAnd1OutputParameter(23), is(equalTo(24)));
|
||||
assertThat(repository.adHocProcedureWith1InputAnd1OutputParameter(23), is(24));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,25 +92,18 @@ public class StoredProcedureIntegrationTests {
|
||||
*/
|
||||
@Test
|
||||
public void shouldExecuteAdHocProcedureWith1InputAndNoOutputParameter() {
|
||||
|
||||
repository.adHocProcedureWith1InputAndNoOutputParameter(42);
|
||||
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAJPA-652
|
||||
*/
|
||||
@Test
|
||||
@Ignore(NOT_SUPPORTED)
|
||||
public void shouldExecuteAdHocProcedureWith1InputAnd1OutputParameterWithResultSet() {
|
||||
|
||||
// hibernate currently (v4.3) doesn't support returning ResultSets in output parameters
|
||||
assumeFalse(currentEntityManagerIsHibernateEntityManager(em));
|
||||
|
||||
List<Dummy> dummies = repository.adHocProcedureWith1InputAnd1OutputParameterWithResultSet("FOO");
|
||||
|
||||
System.out.println("### Found dummies: " + dummies);
|
||||
|
||||
assertThat(dummies, is(notNullValue()));
|
||||
assertThat(dummies.size(), is(equalTo(3)));
|
||||
}
|
||||
@@ -120,15 +112,11 @@ public class StoredProcedureIntegrationTests {
|
||||
* @see DATAJPA-652
|
||||
*/
|
||||
@Test
|
||||
@Ignore(NOT_SUPPORTED)
|
||||
public void shouldExecuteAdHocProcedureWith1InputAnd1OutputParameterWithResultSetWithUpdate() {
|
||||
|
||||
// hibernate currently (v4.3) doesn't support returning ResultSets in output parameters
|
||||
assumeFalse(currentEntityManagerIsHibernateEntityManager(em));
|
||||
|
||||
List<Dummy> dummies = repository.adHocProcedureWith1InputAnd1OutputParameterWithResultSetWithUpdate("FOO");
|
||||
|
||||
System.out.println("### Found dummies: " + dummies);
|
||||
|
||||
assertThat(dummies, is(notNullValue()));
|
||||
assertThat(dummies.size(), is(equalTo(3)));
|
||||
}
|
||||
@@ -138,10 +126,7 @@ public class StoredProcedureIntegrationTests {
|
||||
*/
|
||||
@Test
|
||||
public void shouldExecuteAdHocProcedureWith1InputAnd1OutputParameterWithUpdate() {
|
||||
|
||||
repository.adHocProcedureWith1InputAndNoOutputParameterWithUpdate("FOO");
|
||||
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,7 +134,7 @@ public class StoredProcedureIntegrationTests {
|
||||
*/
|
||||
@Test
|
||||
public void shouldExecuteProcedureWithNoInputAnd1OutputParameter() {
|
||||
assertThat(repository.procedureWithNoInputAnd1OutputParameter(), is(equalTo(42)));
|
||||
assertThat(repository.procedureWithNoInputAnd1OutputParameter(), is(42));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,7 +142,7 @@ public class StoredProcedureIntegrationTests {
|
||||
*/
|
||||
@Test
|
||||
public void shouldExecuteProcedureWith1InputAnd1OutputParameter() {
|
||||
assertThat(repository.procedureWith1InputAnd1OutputParameter(23), is(equalTo(24)));
|
||||
assertThat(repository.procedureWith1InputAnd1OutputParameter(23), is(24));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,21 +150,16 @@ public class StoredProcedureIntegrationTests {
|
||||
*/
|
||||
@Test
|
||||
public void shouldExecuteProcedureWith1InputAndNoOutputParameter() {
|
||||
|
||||
repository.procedureWith1InputAndNoOutputParameter(42);
|
||||
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAJPA-652
|
||||
*/
|
||||
@Test
|
||||
@Ignore(NOT_SUPPORTED)
|
||||
public void shouldExecuteProcedureWith1InputAnd1OutputParameterWithResultSet() {
|
||||
|
||||
// hibernate currently (v4.3) doesn't support returning ResultSets in output parameters
|
||||
assumeFalse(currentEntityManagerIsHibernateEntityManager(em));
|
||||
|
||||
List<Dummy> dummies = repository.procedureWith1InputAnd1OutputParameterWithResultSet("FOO");
|
||||
|
||||
assertThat(dummies, is(notNullValue()));
|
||||
@@ -190,11 +170,9 @@ public class StoredProcedureIntegrationTests {
|
||||
* @see DATAJPA-652
|
||||
*/
|
||||
@Test
|
||||
@Ignore(NOT_SUPPORTED)
|
||||
public void shouldExecuteProcedureWith1InputAnd1OutputParameterWithResultSetWithUpdate() {
|
||||
|
||||
// hibernate currently (v4.3) doesn't support returning ResultSets in output parameters
|
||||
assumeFalse(currentEntityManagerIsHibernateEntityManager(em));
|
||||
|
||||
List<Dummy> dummies = repository.procedureWith1InputAnd1OutputParameterWithResultSetWithUpdate("FOO");
|
||||
|
||||
assertThat(dummies, is(notNullValue()));
|
||||
@@ -206,9 +184,6 @@ public class StoredProcedureIntegrationTests {
|
||||
*/
|
||||
@Test
|
||||
public void shouldExecuteProcedureWith1InputAnd1OutputParameterWithUpdate() {
|
||||
|
||||
repository.procedureWith1InputAndNoOutputParameterWithUpdate("FOO");
|
||||
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2013 the original author or authors.
|
||||
* Copyright 2011-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License
|
||||
import org.springframework.aop.framework.Advised;
|
||||
@@ -59,6 +59,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@ContextConfiguration("classpath:infrastructure.xml")
|
||||
public class PartTreeJpaQueryIntegrationTests {
|
||||
|
||||
private static String PROPERTY = "h.target." + getQueryProperty();
|
||||
|
||||
@Rule public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@PersistenceContext EntityManager entityManager;
|
||||
@@ -106,12 +108,12 @@ public class PartTreeJpaQueryIntegrationTests {
|
||||
|
||||
Query query = jpaQuery.createQuery(new Object[] { "Matthews", new PageRequest(0, 1) });
|
||||
|
||||
HibernateQuery hibernateQuery = getValue(query, "h.target." + (isHibernate43() ? "jpqlQuery" : "val$jpaqlQuery"));
|
||||
HibernateQuery hibernateQuery = getValue(query, PROPERTY);
|
||||
assertThat(hibernateQuery.getHibernateQuery().getQueryString(), endsWith("firstname=:param0"));
|
||||
|
||||
query = jpaQuery.createQuery(new Object[] { null, new PageRequest(0, 1) });
|
||||
|
||||
hibernateQuery = getValue(query, "h.target." + (isHibernate43() ? "jpqlQuery" : "val$jpaqlQuery"));
|
||||
hibernateQuery = getValue(query, PROPERTY);
|
||||
assertThat(hibernateQuery.getHibernateQuery().getQueryString(), endsWith("firstname is null"));
|
||||
}
|
||||
|
||||
@@ -141,10 +143,18 @@ public class PartTreeJpaQueryIntegrationTests {
|
||||
return (T) result;
|
||||
}
|
||||
|
||||
private static String getQueryProperty() {
|
||||
return isHibernate43() || isHibernate5() ? "jpqlQuery" : "val$jpaqlQuery";
|
||||
}
|
||||
|
||||
private static boolean isHibernate43() {
|
||||
return Version.getVersionString().startsWith("4.3");
|
||||
}
|
||||
|
||||
private static boolean isHibernate5() {
|
||||
return Version.getVersionString().startsWith("5.");
|
||||
}
|
||||
|
||||
interface UserRepository extends Repository<User, Long> {
|
||||
|
||||
Page<User> findByFirstname(String firstname, Pageable pageable);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
|
||||
|
||||
<!-- EclipseLink vendor adaptor with workaround platform class for HSQL usage -->
|
||||
<bean id="vendorAdaptor" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter" parent="abstractVendorAdaptor" />
|
||||
<bean id="vendorAdaptor" class="org.springframework.data.jpa.repository.CustomEclipseLinkJpaVendorAdapter" parent="abstractVendorAdaptor" />
|
||||
|
||||
<util:properties id="jpaProperties">
|
||||
<prop key="javax.persistence.jdbc.driver">org.hsqldb.jdbcDriver</prop>
|
||||
|
||||
Reference in New Issue
Block a user