diff --git a/pom.xml b/pom.xml index 49f36d7e04..c30b90c6d7 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.data spring-data-jpa-parent - 4.1.0-SNAPSHOT + 4.1.0-GH-4085-SNAPSHOT pom Spring Data JPA Parent @@ -39,7 +39,7 @@ 9.5.0 42.7.8 23.26.0.0.0 - 4.1.0-SNAPSHOT + 4.1.0-GH-3400-SNAPSHOT 0.10.3 org.hibernate diff --git a/spring-data-envers/pom.xml b/spring-data-envers/pom.xml index c54fa73c20..489be60360 100755 --- a/spring-data-envers/pom.xml +++ b/spring-data-envers/pom.xml @@ -5,12 +5,12 @@ org.springframework.data spring-data-envers - 4.1.0-SNAPSHOT + 4.1.0-GH-4085-SNAPSHOT org.springframework.data spring-data-jpa-parent - 4.1.0-SNAPSHOT + 4.1.0-GH-4085-SNAPSHOT ../pom.xml diff --git a/spring-data-jpa-distribution/pom.xml b/spring-data-jpa-distribution/pom.xml index 954a3a249b..1f7ca82d69 100644 --- a/spring-data-jpa-distribution/pom.xml +++ b/spring-data-jpa-distribution/pom.xml @@ -14,7 +14,7 @@ org.springframework.data spring-data-jpa-parent - 4.1.0-SNAPSHOT + 4.1.0-GH-4085-SNAPSHOT ../pom.xml diff --git a/spring-data-jpa/pom.xml b/spring-data-jpa/pom.xml index d26ca6b94b..eaca7b07bc 100644 --- a/spring-data-jpa/pom.xml +++ b/spring-data-jpa/pom.xml @@ -7,7 +7,7 @@ org.springframework.data spring-data-jpa - 4.1.0-SNAPSHOT + 4.1.0-GH-4085-SNAPSHOT Spring Data JPA Spring Data module for JPA repositories. @@ -16,7 +16,7 @@ org.springframework.data spring-data-jpa-parent - 4.1.0-SNAPSHOT + 4.1.0-GH-4085-SNAPSHOT ../pom.xml diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/criteria/Expressions.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/criteria/Expressions.java new file mode 100644 index 0000000000..ec927b8a71 --- /dev/null +++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/criteria/Expressions.java @@ -0,0 +1,260 @@ +/* + * Copyright 2025 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 + * + * https://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.criteria; + +import jakarta.persistence.criteria.CollectionJoin; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Fetch; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.criteria.ListJoin; +import jakarta.persistence.criteria.MapJoin; +import jakarta.persistence.criteria.Selection; +import jakarta.persistence.criteria.SetJoin; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + +import org.springframework.data.core.PropertyReference; +import org.springframework.data.core.TypedPropertyPath; +import org.springframework.data.jpa.repository.query.QueryUtils; + +/** + * Utility methods to resolve JPA Criteria API objects using Spring Data's type-safe property references. These helper + * methods obtain Criteria API objects using {@link TypedPropertyPath} and {@link PropertyReference} to resolve + * {@link Expression property expressions} and {@link Join joins}. + *

+ * The class is intended for concise, type-aware criteria construction through a type-safe DSL where property references + * are preferred over string-based navigation. + *

+ * Example: + * + *

+ * Root root = criteriaQuery.from(User.class);
+ *
+ * Expression expr = Expressions.get(root, User::getManager);
+ *
+ * Join join = Expressions.join(root, JoinType.INNER, j -> j.join(User::getAddress));
+ * 
+ * + * @author Mark Paluch + * @since 4.1 + * @see PropertyReference + * @see TypedPropertyPath + */ +public abstract class Expressions { + + /** + * Create an {@link Expression} for the given property path. + *

+ * The resulting expression can be used in predicates. Expression resolution navigates joins as necessary. + * + * @param from the root or join to start from. + * @param property property path to navigate. + * @return the expression. + */ + static Expression

get(From from, TypedPropertyPath property) { + return QueryUtils.toExpressionRecursively(from, property, false); + } + + /** + * Create a {@link Selection} for the given property path. + *

+ * The resulting object can be used in the selection, joined paths consider outer joins as needed. + * + * @param from the root or join to start from. + * @param property property path to navigate. + * @return the selection. + */ + static Selection

select(From from, TypedPropertyPath property) { + return QueryUtils.toExpressionRecursively(from, property, true); + } + + /** + * Create a list of {@link Selection selection objects} for the given property paths. + *

+ * The resulting objects can be used in the selection, joined paths consider outer joins as needed. + * + * @param from the root or join to start from. + * @param properties property path to navigate. + * @return the selection. + */ + @SafeVarargs + static List> select(From from, TypedPropertyPath... properties) { + return Arrays.stream(properties).map(it -> get(from, it)).collect(Collectors.toUnmodifiableList()); + } + + /** + * Create a {@link Join} using the given {@link PropertyReference property}. + * + * @param from the root or join to start from. + * @param property property reference to navigate. + * @return the resolved join. + * @see From#join(String) + */ + static Join join(From from, PropertyReference property) { + return from.join(property.getName()); + } + + /** + * Create a {@link Join} considering {@link JoinType} using the given joiner function allowing to express joins using + * property references. + * + * @param from the root or join to start from. + * @param joinType the join type. + * @param function joiner function. + * @return the resolved join. + * @see From#join(String, JoinType) + */ + static > J join(From from, JoinType joinType, Function, J> function) { + return function.apply(new TypedJoiner<>(from, joinType)); + } + + /** + * Create a {@link Fetch fetch join} using the given {@link PropertyReference property}. + * + * @param from the root or join to start from. + * @param property property reference to navigate. + * @return the resolved fetch. + * @see From#fetch(String) + */ + static Fetch fetch(From from, PropertyReference property) { + return from.fetch(property.getName()); + } + + /** + * Create a {@link Fetch fetch join} considering {@link JoinType} using the given fetcher function allowing to express + * fetches using property references. + * + * @param from the root or join to start from. + * @param joinType the join type. + * @param function fetcher function. + * @return the resolved fetch. + * @see From#fetch(String, JoinType) + */ + static > F fetch(From from, JoinType joinType, Function, F> function) { + return function.apply(new TypedFetcher<>(from, joinType)); + } + + private Expressions() {} + + /** + * Strategy interface used by {@link Expressions#join} to obtain joins using property references. + *

+ * Implementations adapt a {@link jakarta.persistence.criteria.From} and expose typed join methods for singular and + * collection-valued attributes as well as map-valued attributes. The methods accept + * {@link org.springframework.data.core.PropertyReference} instances to avoid string-based attribute navigation. + */ + interface Joiner { + + /** + * Create a join for the given property. + * + * @param property the property to join. + * @see From#join + */ +

Join join(PropertyReference property); + + /** + * Create a collection join for the given property. + * + * @param property the property to join. + * @see From#joinCollection + */ +

CollectionJoin joinCollection(PropertyReference property); + + /** + * Create a list join for the given property. + * + * @param property the property to join. + * @see From#joinList + */ +

ListJoin joinList(PropertyReference property); + + /** + * Create a set join for the given property. + * + * @param property the property to join. + * @see From#joinSet + */ +

SetJoin joinSet(PropertyReference property); + + /** + * Create a map join for the given property. + * + * @param property the property to join. + * @see From#joinMap + */ + > MapJoin joinMap(PropertyReference property); + + } + + record TypedJoiner(From from, JoinType type) implements Joiner { + + public

Join join(PropertyReference property) { + return from.join(property.getName(), type); + } + + public

CollectionJoin joinCollection(PropertyReference property) { + return from.joinCollection(property.getName(), type); + } + + public

ListJoin joinList(PropertyReference property) { + return from.joinList(property.getName(), type); + } + + public

SetJoin joinSet(PropertyReference property) { + return from.joinSet(property.getName(), type); + } + + public > MapJoin joinMap(PropertyReference property) { + return from.joinMap(property.getName(), type); + } + + } + + /** + * Strategy interface used by {@link Expressions#fetch} to obtain fetch joins using property references. + *

+ * Implementations adapt a {@link jakarta.persistence.criteria.From} and expose typed fetch methods accepting + * {@link org.springframework.data.core.PropertyReference} instances to avoid string-based attribute navigation. + */ + interface Fetcher { + + /** + * Create a fetch join for the given property. + * + * @param property the property to join. + * @see From#fetch + */ +

Fetch fetch(PropertyReference property); + + } + + record TypedFetcher(From from, JoinType type) implements Fetcher { + + @Override + public

Fetch fetch(PropertyReference property) { + return from.fetch(property.getName(), type); + } + + } + +} diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/criteria/package-info.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/criteria/package-info.java new file mode 100644 index 0000000000..12d8f89363 --- /dev/null +++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/criteria/package-info.java @@ -0,0 +1,21 @@ +/* + * Copyright 2025 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 + * + * https://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. + */ + +/** + * JPA Criteria Query support. + */ +@org.jspecify.annotations.NullMarked +package org.springframework.data.jpa.criteria; diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/criteria/ExpressionsTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/criteria/ExpressionsTests.java new file mode 100644 index 0000000000..58664854f1 --- /dev/null +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/criteria/ExpressionsTests.java @@ -0,0 +1,153 @@ +/* + * Copyright 2025 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 + * + * https://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.criteria; + +import static org.assertj.core.api.Assertions.*; + +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Fetch; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Root; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.core.TypedPropertyPath; +import org.springframework.data.jpa.domain.sample.Role; +import org.springframework.data.jpa.domain.sample.User; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; + +/** + * Integration tests for {@link Expressions}. + * + * @author Mark Paluch + */ +@SpringJUnitConfig(locations = "classpath:hibernate-h2-infrastructure.xml") +class ExpressionsTests { + + @Autowired EntityManager entityManager; + + @BeforeEach + void setUp() { + System.setProperty("spring.data.lambda-reader.filter-stacktrace", "false"); + } + + @Test // GH-4085 + void shouldResolveTopLevelExpression() { + + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + CriteriaQuery query = cb.createQuery(); + Root from = query.from(User.class); + + Expression expression = Expressions.get(from, User::getFirstname); + assertThat(expression.getJavaType()).isEqualTo(String.class); + } + + @Test // GH-4085 + void shouldResolveNestedLevelExpression() { + + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + CriteriaQuery query = cb.createQuery(); + Root from = query.from(User.class); + + Expression expression = Expressions.get(from, + TypedPropertyPath.of(User::getManager).thenMany(User::getRoles)); + assertThat(expression.getJavaType()).isEqualTo(Role.class); + } + + @Test // GH-4085 + void shouldSelectExpression() { + + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + CriteriaQuery query = cb.createQuery(); + Root from = query.from(User.class); + + Path path = (Path) Expressions.select(from, User::getFirstname); + + assertThat(path.getJavaType()).isEqualTo(String.class); + assertThat(path.getParentPath()).isEqualTo(from); + } + + @Test // GH-4085 + void shouldSelectJoinedExpression() { + + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + CriteriaQuery query = cb.createQuery(); + Root from = query.from(User.class); + + Path path = (Path) Expressions.select(from, TypedPropertyPath.of(User::getManager).then(User::getLastname)); + + assertThat(path.getParentPath()).isInstanceOf(Join.class); + } + + @Test // GH-4085 + void shouldJoin() { + + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + CriteriaQuery query = cb.createQuery(); + Root from = query.from(User.class); + + Join join = Expressions.join(from, User::getManager); + + assertThat(join.getJavaType()).isEqualTo(User.class); + assertThat(join.getAttribute().getName()).isEqualTo("manager"); + } + + @Test // GH-4085 + void shouldJoinWithType() { + + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + CriteriaQuery query = cb.createQuery(); + Root from = query.from(User.class); + + Join join = Expressions.join(from, JoinType.LEFT, it -> it.join(User::getManager)); + + assertThat(join.getJavaType()).isEqualTo(User.class); + assertThat(join.getJoinType()).isEqualTo(JoinType.LEFT); + } + + @Test // GH-4085 + void shouldFetch() { + + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + CriteriaQuery query = cb.createQuery(); + Root from = query.from(User.class); + + Fetch fetch = Expressions.fetch(from, User::getManager); + + assertThat(fetch.getAttribute().getName()).isEqualTo("manager"); + } + + @Test // GH-4085 + void shouldFetchWithType() { + + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + CriteriaQuery query = cb.createQuery(); + Root from = query.from(User.class); + + Fetch fetch = Expressions.fetch(from, JoinType.LEFT, it -> it.fetch(User::getManager)); + + assertThat(fetch.getAttribute().getName()).isEqualTo("manager"); + assertThat(fetch.getJoinType()).isEqualTo(JoinType.LEFT); + } + +} diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/JpaSortTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/JpaSortTests.java index c64d55f7f7..999503b1b9 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/JpaSortTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/JpaSortTests.java @@ -46,7 +46,7 @@ * @author Jens Schauder */ @ExtendWith(SpringExtension.class) -@ContextConfiguration("classpath:infrastructure.xml") +@ContextConfiguration("classpath:hibernate-infrastructure.xml") class JpaSortTests { private static final @Nullable Attribute NULL_ATTRIBUTE = null; diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/support/QueryByExampleWithOptionalEmptyTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/support/QueryByExampleWithOptionalEmptyTests.java index 21c04b3145..0a89fe67fa 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/support/QueryByExampleWithOptionalEmptyTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/support/QueryByExampleWithOptionalEmptyTests.java @@ -64,7 +64,7 @@ void queryByExampleTreatsEmptyOptionalsLikeNulls() { @Configuration @EnableJpaRepositories(basePackageClasses = UserWithOptionalFieldRepository.class) - @ImportResource("classpath:infrastructure.xml") + @ImportResource("classpath:hibernate-infrastructure.xml") static class JpaRepositoryConfig {} } diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/infrastructure/MetamodelIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/infrastructure/MetamodelIntegrationTests.java index c821dd76a5..33fdc1b0bf 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/infrastructure/MetamodelIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/infrastructure/MetamodelIntegrationTests.java @@ -47,7 +47,7 @@ * @author Jens Schauder */ @ExtendWith(SpringExtension.class) -@ContextConfiguration({ "classpath:infrastructure.xml" }) +@ContextConfiguration("classpath:hibernate-infrastructure.xml") abstract class MetamodelIntegrationTests { @PersistenceContext EntityManager em; diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/mapping/JpaMetamodelMappingContextIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/mapping/JpaMetamodelMappingContextIntegrationTests.java index 4e2d3c32ea..8f528dbf3f 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/mapping/JpaMetamodelMappingContextIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/mapping/JpaMetamodelMappingContextIntegrationTests.java @@ -189,7 +189,7 @@ void traversesEmbeddablesButNoOtherMappingAnnotations() { } @Configuration - @ImportResource("classpath:infrastructure.xml") + @ImportResource("classpath:hibernate-infrastructure.xml") @EnableJpaRepositories(basePackageClasses = CategoryRepository.class, // includeFilters = @Filter(value = { CategoryRepository.class, ProductRepository.class }, type = FilterType.ASSIGNABLE_TYPE)) diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/provider/PersistenceProviderIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/provider/PersistenceProviderIntegrationTests.java index 0f27bd1422..4df379ccd2 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/provider/PersistenceProviderIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/provider/PersistenceProviderIntegrationTests.java @@ -84,7 +84,7 @@ public Void doInTransaction(TransactionStatus status) { } @Configuration - @ImportResource("classpath:infrastructure.xml") + @ImportResource("classpath:hibernate-infrastructure.xml") @EnableJpaRepositories(basePackageClasses = CategoryRepository.class, // includeFilters = @Filter(value = { CategoryRepository.class, ProductRepository.class }, type = FilterType.ASSIGNABLE_TYPE)) diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/AotUserRepositoryTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/AotUserRepositoryTests.java index c35bafb0e3..d9a7dd6b47 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/AotUserRepositoryTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/AotUserRepositoryTests.java @@ -53,7 +53,7 @@ class AotUserRepositoryTests extends UserRepositoryTests { @Configuration - @ImportResource("classpath:/infrastructure.xml") + @ImportResource("classpath:hibernate-infrastructure.xml") static class Config { @PersistenceContext EntityManager entityManager; diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/CustomerRepositoryProjectionTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/CustomerRepositoryProjectionTests.java index 73d6a6bb54..67087fcc44 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/CustomerRepositoryProjectionTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/CustomerRepositoryProjectionTests.java @@ -22,7 +22,6 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.jpa.domain.sample.Country; import org.springframework.data.jpa.domain.sample.Customer; @@ -37,7 +36,8 @@ * @author Mark Paluch */ @ExtendWith(SpringExtension.class) -@ContextConfiguration(locations = "classpath:config/namespace-application-context-h2.xml") +@ContextConfiguration( + locations = { "classpath:config/namespace-application-context.xml", "classpath:hibernate-h2-infrastructure.xml" }) @Transactional class CustomerRepositoryProjectionTests { diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EclipseLinkQueryByExampleIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EclipseLinkQueryByExampleIntegrationTests.java index 1f0e5e1300..a784e05eae 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EclipseLinkQueryByExampleIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EclipseLinkQueryByExampleIntegrationTests.java @@ -41,7 +41,8 @@ * @since 3.0 */ @ExtendWith(SpringExtension.class) -@ContextConfiguration({ "classpath:eclipselink.xml", "classpath:config/namespace-application-context.xml" }) +@ContextConfiguration({ "classpath:eclipselink-infrastructure.xml", + "classpath:config/namespace-application-context.xml" }) @Transactional class EclipseLinkQueryByExampleIntegrationTests { diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EclipseLinkUserRepositoryFinderTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EclipseLinkUserRepositoryFinderTests.java index 9ad2fe8f3c..b17c13694e 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EclipseLinkUserRepositoryFinderTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EclipseLinkUserRepositoryFinderTests.java @@ -25,7 +25,8 @@ * @author Oliver Gierke * @author Greg Turnquist */ -@ContextConfiguration("classpath:eclipselink-h2.xml") +@ContextConfiguration(value = { "classpath:config/namespace-application-context.xml", "classpath:eclipselink.xml", + "classpath:h2.xml", "classpath:infrastructure.xml" }, inheritLocations = false) class EclipseLinkUserRepositoryFinderTests extends UserRepositoryFinderTests { @Disabled diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EclipseLinkUserRepositoryProjectionTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EclipseLinkUserRepositoryProjectionTests.java index d4d6e2a14f..65b746b0f2 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EclipseLinkUserRepositoryProjectionTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EclipseLinkUserRepositoryProjectionTests.java @@ -22,7 +22,9 @@ * @author Oliver Gierke * @author Greg Turnquist */ -@ContextConfiguration("classpath:eclipselink-h2.xml") +@ContextConfiguration( + value = { "classpath:config/namespace-application-context.xml", "classpath:eclipselink-infrastructure.xml" }, + inheritLocations = false) class EclipseLinkUserRepositoryProjectionTests extends UserRepositoryProjectionTests { @Disabled diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EclipselinkRepositoryWithCompositeKeyTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EclipselinkRepositoryWithCompositeKeyTests.java index 5eb94caf89..b591c872d7 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EclipselinkRepositoryWithCompositeKeyTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EclipselinkRepositoryWithCompositeKeyTests.java @@ -29,7 +29,7 @@ @ContextConfiguration class EclipselinkRepositoryWithCompositeKeyTests extends RepositoryWithCompositeKeyTests { - @ImportResource({ "classpath:infrastructure.xml", "classpath:eclipselink.xml" }) + @ImportResource({ "classpath:hibernate-infrastructure.xml", "classpath:eclipselink.xml" }) static class TestConfig extends RepositoryWithIdClassKeyTests.Config {} @Override diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EntityWithAssignedIdIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EntityWithAssignedIdIntegrationTests.java index 05e6714895..ece4affe99 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EntityWithAssignedIdIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EntityWithAssignedIdIntegrationTests.java @@ -19,7 +19,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.jpa.domain.sample.EntityWithAssignedId; import org.springframework.data.jpa.repository.sample.EntityWithAssignedIdRepository; @@ -31,7 +30,8 @@ * @author Oliver Drotbohm */ @ExtendWith(SpringExtension.class) -@ContextConfiguration("classpath:config/namespace-application-context.xml") +@ContextConfiguration( + locations = { "classpath:config/namespace-application-context.xml", "classpath:hibernate-infrastructure.xml" }) @Transactional class EntityWithAssignedIdIntegrationTests { diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/HibernateRepositoryTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/HibernateRepositoryTests.java index 5f965f203e..d46276563b 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/HibernateRepositoryTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/HibernateRepositoryTests.java @@ -90,7 +90,7 @@ void testQueryWithCTE() { assertThat(result.getTotalElements()).isEqualTo(3); } - @ImportResource({ "classpath:infrastructure.xml" }) + @ImportResource({ "classpath:hibernate-infrastructure.xml" }) @Configuration @EnableJpaRepositories(basePackageClasses = HibernateRepositoryTests.class, considerNestedRepositories = true, includeFilters = @ComponentScan.Filter( diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/JavaConfigUserRepositoryTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/JavaConfigUserRepositoryTests.java index f40877701e..e6c4b8163a 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/JavaConfigUserRepositoryTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/JavaConfigUserRepositoryTests.java @@ -58,7 +58,7 @@ class JavaConfigUserRepositoryTests extends UserRepositoryTests { @Configuration - @ImportResource("classpath:infrastructure.xml") + @ImportResource("classpath:hibernate-infrastructure.xml") static class Config { @PersistenceContext EntityManager entityManager; @@ -115,6 +115,6 @@ void doesNotPickUpJpaRepository() { @Configuration @EnableJpaRepositories(basePackageClasses = UserRepository.class) - @ImportResource("classpath:infrastructure.xml") + @ImportResource("classpath:hibernate-infrastructure.xml") static class JpaRepositoryConfig {} } diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/NamespaceUserRepositoryTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/NamespaceUserRepositoryTests.java index 5c99719d12..a5b5f8d619 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/NamespaceUserRepositoryTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/NamespaceUserRepositoryTests.java @@ -31,11 +31,12 @@ * @author Oliver Gierke * @author Eberhard Wolff */ -@ContextConfiguration(locations = "classpath:config/namespace-application-context.xml", inheritLocations = false) +@ContextConfiguration( + locations = { "classpath:config/namespace-application-context.xml", "classpath:hibernate-infrastructure.xml" }, + inheritLocations = false) class NamespaceUserRepositoryTests extends UserRepositoryTests { - @Autowired - ListableBeanFactory beanFactory; + @Autowired ListableBeanFactory beanFactory; @Test void registersPostProcessors() { diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/ORMInfrastructureTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/ORMInfrastructureTests.java index 5cbb6a96bb..3b5f4b46cd 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/ORMInfrastructureTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/ORMInfrastructureTests.java @@ -32,7 +32,7 @@ * @author Jens Schauder */ @ExtendWith(SpringExtension.class) -@ContextConfiguration(locations = "classpath:infrastructure.xml") +@ContextConfiguration(locations = "classpath:hibernate-infrastructure.xml") class ORMInfrastructureTests { @Autowired ApplicationContext context; diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/ParentRepositoryIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/ParentRepositoryIntegrationTests.java index 7b53e6669b..e00506c976 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/ParentRepositoryIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/ParentRepositoryIntegrationTests.java @@ -15,7 +15,7 @@ */ package org.springframework.data.jpa.repository; -import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.*; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaQuery; @@ -47,7 +47,8 @@ */ @Transactional @ExtendWith(SpringExtension.class) -@ContextConfiguration("classpath:config/namespace-application-context.xml") +@ContextConfiguration( + locations = { "classpath:config/namespace-application-context.xml", "classpath:hibernate-infrastructure.xml" }) class ParentRepositoryIntegrationTests { @Autowired ParentRepository repository; diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/QueryByExampleIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/QueryByExampleIntegrationTests.java index fa9de5e26f..041c70f31f 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/QueryByExampleIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/QueryByExampleIntegrationTests.java @@ -15,7 +15,7 @@ */ package org.springframework.data.jpa.repository; -import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.*; import jakarta.persistence.EntityManager; import jakarta.persistence.criteria.CriteriaBuilder; @@ -47,7 +47,8 @@ * @since 3.0 */ @ExtendWith(SpringExtension.class) -@ContextConfiguration({ "classpath:hibernate.xml", "classpath:config/namespace-application-context.xml" }) +@ContextConfiguration({ "classpath:hibernate-infrastructure.xml", + "classpath:config/namespace-application-context.xml" }) @Transactional class QueryByExampleIntegrationTests { diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/RepositoryWithIdClassKeyTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/RepositoryWithIdClassKeyTests.java index 5cc0f45ce0..44274f7ab7 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/RepositoryWithIdClassKeyTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/RepositoryWithIdClassKeyTests.java @@ -108,6 +108,6 @@ static abstract class Config { } - @ImportResource("classpath:infrastructure.xml") + @ImportResource("classpath:hibernate-infrastructure.xml") static class TestConfig extends Config {} } diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/SPR8954Tests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/SPR8954Tests.java index f2a0042a32..7f3ca1bb62 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/SPR8954Tests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/SPR8954Tests.java @@ -15,7 +15,7 @@ */ package org.springframework.data.jpa.repository; -import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.*; import java.util.Map; @@ -34,7 +34,8 @@ * @author Krzysztof Krason */ @ExtendWith(SpringExtension.class) -@ContextConfiguration("classpath:config/namespace-application-context.xml") +@ContextConfiguration( + locations = { "classpath:config/namespace-application-context.xml", "classpath:hibernate-infrastructure.xml" }) class SPR8954Tests { @Autowired ApplicationContext context; diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/StoredProcedureIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/StoredProcedureIntegrationTests.java index 8cc377e059..5b445d20b9 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/StoredProcedureIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/StoredProcedureIntegrationTests.java @@ -150,6 +150,6 @@ void shouldExecuteProcedureWith1InputAnd1OutputParameterWithUpdate() { includeFilters = { @Filter(pattern = ".*DummyRepository", type = FilterType.REGEX) }) static abstract class Config {} - @ImportResource("classpath:infrastructure.xml") + @ImportResource("classpath:hibernate-infrastructure.xml") static class TestConfig extends Config {} } diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/UserRepositoryFinderTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/UserRepositoryFinderTests.java index 2c73a64803..436a0fa070 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/UserRepositoryFinderTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/UserRepositoryFinderTests.java @@ -27,7 +27,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.data.domain.Limit; @@ -61,7 +60,8 @@ * @see QueryLookupStrategy */ @ExtendWith(SpringExtension.class) -@ContextConfiguration(locations = "classpath:config/namespace-application-context-h2.xml") +@ContextConfiguration( + locations = { "classpath:config/namespace-application-context.xml", "classpath:hibernate-h2-infrastructure.xml" }) @Transactional class UserRepositoryFinderTests { diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/UserRepositoryProjectionTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/UserRepositoryProjectionTests.java index 8771939ac4..f9a69ecc03 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/UserRepositoryProjectionTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/UserRepositoryProjectionTests.java @@ -29,7 +29,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; @@ -61,7 +60,8 @@ * @see QueryLookupStrategy */ @ExtendWith(SpringExtension.class) -@ContextConfiguration(locations = "classpath:config/namespace-application-context-h2.xml") +@ContextConfiguration( + locations = { "classpath:config/namespace-application-context.xml", "classpath:hibernate-h2-infrastructure.xml" }) @Transactional class UserRepositoryProjectionTests { @@ -279,7 +279,7 @@ void dtoProjectionWithEntityAndAggregatedValueWithPageable() { @ValueSource(classes = { UserRoleCountDtoProjection.class, UserRoleCountInterfaceProjection.class }) void dynamicProjectionWithEntityAndAggregated(Class resultType) { - assertThat(userRepository.findMultiselectRecordDynamicProjection(resultType)).hasSize(3) + assertThat(userRepository.findMultiselectRecordDynamicProjection(resultType)).hasSizeGreaterThan(1) .hasOnlyElementsOfType(resultType); } diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/aot/AotFragmentTestConfigurationSupport.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/aot/AotFragmentTestConfigurationSupport.java index 960b1a4410..6b9aa2871d 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/aot/AotFragmentTestConfigurationSupport.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/aot/AotFragmentTestConfigurationSupport.java @@ -65,7 +65,7 @@ * * @author Mark Paluch */ -@ImportResource("classpath:/infrastructure.xml") +@ImportResource("classpath:hibernate-infrastructure.xml") public class AotFragmentTestConfigurationSupport implements BeanFactoryPostProcessor { private final Class repositoryInterface; diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/config/NestedRepositoriesJavaConfigTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/config/NestedRepositoriesJavaConfigTests.java index 7384a64cb6..beac314224 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/config/NestedRepositoriesJavaConfigTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/config/NestedRepositoriesJavaConfigTests.java @@ -49,6 +49,6 @@ void shouldSupportNestedRepositories() { @Configuration @EnableJpaRepositories(basePackageClasses = UserRepository.class, considerNestedRepositories = true) - @ImportResource("classpath:infrastructure.xml") + @ImportResource("classpath:hibernate-infrastructure.xml") static class Config {} } diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/config/RepositoriesJavaConfigTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/config/RepositoriesJavaConfigTests.java index bb40ccfc01..11ce4e9f9b 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/config/RepositoriesJavaConfigTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/config/RepositoriesJavaConfigTests.java @@ -50,7 +50,7 @@ void foo() { @Configuration @EnableJpaRepositories(basePackageClasses = UserRepository.class) - @ImportResource("classpath:infrastructure.xml") + @ImportResource("classpath:hibernate-infrastructure.xml") static class Config { @Autowired ApplicationContext context; diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/config/RepositoryConfigTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/config/RepositoryConfigTests.java index 722e137690..d9b5687510 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/config/RepositoryConfigTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/config/RepositoryConfigTests.java @@ -22,6 +22,7 @@ * * @author Oliver Gierke */ -@ContextConfiguration(locations = "classpath:config/namespace-application-context.xml") +@ContextConfiguration( + locations = { "classpath:config/namespace-application-context.xml", "classpath:hibernate-infrastructure.xml" }) class RepositoryConfigTests extends AbstractRepositoryConfigTests { } diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/generics/EclipseLinkGenericsIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/generics/EclipseLinkGenericsIntegrationTests.java index 9c3019106f..dabd378e9e 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/generics/EclipseLinkGenericsIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/generics/EclipseLinkGenericsIntegrationTests.java @@ -25,7 +25,7 @@ */ @Transactional @ExtendWith(SpringExtension.class) -@ContextConfiguration({ "classpath:eclipselink.xml", "classpath:config/namespace-application-context.xml" }) +@ContextConfiguration({ "classpath:eclipselink-infrastructure.xml" }) class EclipseLinkGenericsIntegrationTests extends GenericsIntegrationTests { } diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/AbstractJpaQueryTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/AbstractJpaQueryTests.java index 3d9a616120..a51657548f 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/AbstractJpaQueryTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/AbstractJpaQueryTests.java @@ -57,7 +57,7 @@ * @author Julia Lee */ @ExtendWith(SpringExtension.class) -@ContextConfiguration("classpath:infrastructure.xml") +@ContextConfiguration("classpath:hibernate-infrastructure.xml") class AbstractJpaQueryTests { @PersistenceContext EntityManager em; diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/AbstractStringBasedJpaQueryIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/AbstractStringBasedJpaQueryIntegrationTests.java index 3d77980fb6..3f19e82b3e 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/AbstractStringBasedJpaQueryIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/AbstractStringBasedJpaQueryIntegrationTests.java @@ -49,7 +49,7 @@ * @soundtrack Henrik Freischlader Trio - Nobody Else To Blame (Openness) */ @ExtendWith(SpringExtension.class) -@ContextConfiguration("classpath:infrastructure.xml") +@ContextConfiguration("classpath:hibernate-infrastructure.xml") class AbstractStringBasedJpaQueryIntegrationTests { private static final JpaQueryConfiguration CONFIG = new JpaQueryConfiguration(QueryRewriterProvider.simple(), diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/CustomNonBindableJpaParametersIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/CustomNonBindableJpaParametersIntegrationTests.java index 8df1d28be3..408f64bc1b 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/CustomNonBindableJpaParametersIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/CustomNonBindableJpaParametersIntegrationTests.java @@ -107,7 +107,7 @@ public JpaQueryMethod build(Method method, RepositoryMetadata metadata, Projecti } @Configuration - @ImportResource("classpath:infrastructure.xml") + @ImportResource("classpath:hibernate-infrastructure.xml") @EnableJpaRepositories(considerNestedRepositories = true, basePackageClasses = ProductRepository.class, // includeFilters = @ComponentScan.Filter(value = { ProductRepository.class }, type = FilterType.ASSIGNABLE_TYPE)) static class Config { diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/EclipseLinkMetaAnnotatedQueryMethodIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/EclipseLinkMetaAnnotatedQueryMethodIntegrationTests.java deleted file mode 100644 index bf8e408d52..0000000000 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/EclipseLinkMetaAnnotatedQueryMethodIntegrationTests.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright 2013-2025 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 - * - * https://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.query; - -import static org.assertj.core.api.Assertions.*; - -import jakarta.persistence.EntityManagerFactory; - -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Reader; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Properties; - -import javax.sql.DataSource; - -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.io.DefaultResourceLoader; -import org.springframework.core.io.ResourceLoader; -import org.springframework.data.domain.Example; -import org.springframework.data.domain.Sort; -import org.springframework.data.jpa.domain.sample.Role; -import org.springframework.data.jpa.repository.Meta; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.data.jpa.repository.sample.RoleRepositoryWithMeta; -import org.springframework.data.repository.query.FluentQuery; -import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; -import org.springframework.orm.jpa.JpaDialect; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.orm.jpa.vendor.AbstractJpaVendorAdapter; -import org.springframework.orm.jpa.vendor.Database; -import org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect; -import org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.FileCopyUtils; - -/** - * Verify that {@link Meta}-annotated methods properly embed comments into EclipseLink queries. - * - * @author Greg Turnquist - * @author Edoardo Patti - * @since 3.0 - */ -@ExtendWith(SpringExtension.class) -@ContextConfiguration -@Transactional -class EclipseLinkMetaAnnotatedQueryMethodIntegrationTests { - - @Autowired RoleRepositoryWithMeta repository; - - private static final ResourceLoader RESOURCE_LOADER = new DefaultResourceLoader(); - private static String LOG_FILE; - - private static Path logFile; - - @BeforeAll - static void createLogfile() throws IOException { - logFile = Files.createTempFile("test-eclipselink-meta", ".log"); - LOG_FILE = logFile.toAbsolutePath().toString(); - } - - @AfterAll - static void deleteLogFile() { - logFile.toFile().deleteOnExit(); - } - - @Test // GH-775 - void findAllShouldLogAComment() { - - repository.findAll(); - - assertAtLeastOneComment(); - } - - @Test // GH-775 - void findByIdShouldLogAComment() { - - repository.findById(0); - - assertAtLeastOneComment(); - } - - @Test // GH-775 - void existsByIdShouldLogAComment() { - - repository.existsById(0); - - assertAtLeastOneComment(); - } - - @Test // GH-775 - void customFinderShouldLogAComment() throws Exception { - - repository.findByName("name"); - - assertAtLeastOneComment(); - } - - @Test // GH-775 - void findOneWithExampleShouldLogAComment() { - - repository.findOne(Example.of(new Role())); - - assertAtLeastOneComment(); - } - - @Test // GH-775 - void findAllWithExampleShouldLogAComment() { - - repository.findAll(Example.of(new Role())); - - assertAtLeastOneComment(); - } - - @Test // GH-775 - void findAllWithExampleAndSortShouldLogAComment() { - - repository.findAll(Example.of(new Role()), Sort.by("name")); - - assertAtLeastOneComment(); - } - - @Test // GH-775 - void findByFluentDslWithExampleShouldLogAComment() { - - repository.findBy(Example.of(new Role()), FluentQuery.FetchableFluentQuery::all); - - assertAtLeastOneComment(); - } - - @Test // GH-775 - void existsByExampleShouldLogAComment() { - - repository.exists(Example.of(new Role())); - - assertAtLeastOneComment(); - } - - @Test // GH-775 - void countShouldLogAComment() { - - repository.count(); - - assertAtLeastOneComment(); - } - - @Test // GH-775 - void customCountShouldLogAComment() { - - repository.countByName("name"); - - assertAtLeastOneComment(); - } - - @Test // GH-775 - void deleteAllInBatchShouldLogAComment() { - - repository.deleteAllInBatch(); - - assertAtLeastOneComment(); - } - - void assertAtLeastOneComment() { - - try (Reader reader = new InputStreamReader(RESOURCE_LOADER.getResource("file:" + LOG_FILE).getInputStream(), - StandardCharsets.UTF_8)) { - - String logFileOutput = FileCopyUtils.copyToString(reader); - assertThat(logFileOutput).contains("/* foobar */"); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Configuration - @EnableJpaRepositories(basePackages = "org.springframework.data.jpa.repository.sample") - static class Config { - - @Bean - public DataSource dataSource() { - return new EmbeddedDatabaseBuilder().generateUniqueName(true).build(); - } - - @Bean - public Properties jpaProperties() { - - Properties properties = new Properties(); - properties.put("eclipselink.weaving", "false"); - properties.put("eclipselink.logging.level.sql", "FINE"); - properties.put("eclipselink.logging.file", LOG_FILE); - return properties; - } - - @Bean - public AbstractJpaVendorAdapter vendorAdaptor() { - - EclipseLinkJpaVendorAdapter vendorAdapter = new EclipseLinkJpaVendorAdapter(); - vendorAdapter.setGenerateDdl(true); - vendorAdapter.setDatabase(Database.HSQL); - return vendorAdapter; - } - - @Bean - public EntityManagerFactory entityManagerFactory() { - - LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); - factory.setDataSource(dataSource()); - factory.setPersistenceUnitName("spring-data-jpa"); - factory.setJpaVendorAdapter(vendorAdaptor()); - factory.setJpaProperties(jpaProperties()); - factory.afterPropertiesSet(); - return factory.getObject(); - } - - @Bean - public JpaDialect jpaDialect() { - return new EclipseLinkJpaDialect(); - } - - @Bean - public PlatformTransactionManager transactionManager() { - return new JpaTransactionManager(entityManagerFactory()); - } - } -} diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/HibernateJpaParametersParameterAccessorUnitTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/HibernateJpaParametersParameterAccessorUnitTests.java index b43e164a37..e2d13fa2e6 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/HibernateJpaParametersParameterAccessorUnitTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/HibernateJpaParametersParameterAccessorUnitTests.java @@ -22,7 +22,7 @@ * @author Cedomir Igaly */ @ExtendWith(SpringExtension.class) -@ContextConfiguration("classpath:infrastructure.xml") +@ContextConfiguration("classpath:hibernate-infrastructure.xml") class HibernateJpaParametersParameterAccessorUnitTests { @Autowired private EntityManager em; diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpaCountQueryCreatorIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpaCountQueryCreatorIntegrationTests.java index d44c40301c..a290571390 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpaCountQueryCreatorIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpaCountQueryCreatorIntegrationTests.java @@ -44,7 +44,7 @@ * @author Jens Schauder */ @ExtendWith(SpringExtension.class) -@ContextConfiguration("classpath:infrastructure.xml") +@ContextConfiguration("classpath:hibernate-infrastructure.xml") class JpaCountQueryCreatorIntegrationTests { @PersistenceContext EntityManager entityManager; diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpaKeysetScrollQueryCreatorTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpaKeysetScrollQueryCreatorTests.java index b6612bfb71..13a21b0f62 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpaKeysetScrollQueryCreatorTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpaKeysetScrollQueryCreatorTests.java @@ -46,7 +46,7 @@ * @author Mark Paluch */ @ExtendWith(SpringExtension.class) -@ContextConfiguration("classpath:infrastructure.xml") +@ContextConfiguration("classpath:hibernate-infrastructure.xml") class JpaKeysetScrollQueryCreatorTests { @PersistenceContext EntityManager entityManager; diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpaParametersParameterAccessorTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpaParametersParameterAccessorTests.java index 22b8fcaa6c..ab619f63ea 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpaParametersParameterAccessorTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpaParametersParameterAccessorTests.java @@ -26,7 +26,7 @@ * @author Wonchul Heo */ @ExtendWith(SpringExtension.class) -@ContextConfiguration("classpath:infrastructure.xml") +@ContextConfiguration("classpath:hibernate-infrastructure.xml") class JpaParametersParameterAccessorTests { @PersistenceContext private EntityManager em; diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpaQueryRewriteIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpaQueryRewriteIntegrationTests.java index 2d44dbf0a5..209534aae8 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpaQueryRewriteIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpaQueryRewriteIntegrationTests.java @@ -237,7 +237,7 @@ private static String replaceAlias(String query, Sort sort) { } @Configuration - @ImportResource("classpath:infrastructure.xml") + @ImportResource("classpath:hibernate-infrastructure.xml") @EnableJpaRepositories(considerNestedRepositories = true, basePackageClasses = UserRepositoryWithRewriter.class, // includeFilters = @ComponentScan.Filter(value = { UserRepositoryWithRewriter.class }, type = FilterType.ASSIGNABLE_TYPE), diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/KeysetScrollSpecificationUnitTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/KeysetScrollSpecificationUnitTests.java index 9d8c92a18a..f634ed6a8d 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/KeysetScrollSpecificationUnitTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/KeysetScrollSpecificationUnitTests.java @@ -38,7 +38,7 @@ * @author Mark Paluch */ @ExtendWith(SpringExtension.class) -@ContextConfiguration({ "classpath:infrastructure.xml" }) +@ContextConfiguration("classpath:hibernate-infrastructure.xml") @Transactional class KeysetScrollSpecificationUnitTests { diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/ParameterMetadataProviderIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/ParameterMetadataProviderIntegrationTests.java index 963d742dd1..03e6b84020 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/ParameterMetadataProviderIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/ParameterMetadataProviderIntegrationTests.java @@ -49,7 +49,7 @@ * @soundtrack Elephants Crossing - We are (Irrelephant) */ @ExtendWith(SpringExtension.class) -@ContextConfiguration("classpath:infrastructure.xml") +@ContextConfiguration("classpath:hibernate-infrastructure.xml") class ParameterMetadataProviderIntegrationTests { @PersistenceContext EntityManager em; diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/PartTreeJpaQueryIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/PartTreeJpaQueryIntegrationTests.java index 3b1fe54569..7459604a8b 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/PartTreeJpaQueryIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/PartTreeJpaQueryIntegrationTests.java @@ -65,7 +65,7 @@ * @author Christoph Strobl */ @ExtendWith(SpringExtension.class) -@ContextConfiguration("classpath:infrastructure.xml") +@ContextConfiguration("classpath:hibernate-infrastructure.xml") class PartTreeJpaQueryIntegrationTests { private static String PROPERTY = "h.target." + getQueryProperty(); diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/QueryUtilsIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/QueryUtilsIntegrationTests.java index 3b2a3a05da..bc1960dd35 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/QueryUtilsIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/QueryUtilsIntegrationTests.java @@ -78,7 +78,7 @@ * @author Jakub Soltys */ @ExtendWith(SpringExtension.class) -@ContextConfiguration("classpath:infrastructure.xml") +@ContextConfiguration("classpath:hibernate-infrastructure.xml") class QueryUtilsIntegrationTests { @PersistenceContext EntityManager em; diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/sample/SampleConfig.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/sample/SampleConfig.java index a319360651..70addb7223 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/sample/SampleConfig.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/sample/SampleConfig.java @@ -23,7 +23,7 @@ * @author Oliver Gierke */ @Configuration -@ImportResource("classpath:infrastructure.xml") +@ImportResource("classpath:hibernate-infrastructure.xml") @EnableJpaRepositories public class SampleConfig { diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/EclipseLinkJpaMetamodelEntityInformationIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/EclipseLinkJpaMetamodelEntityInformationIntegrationTests.java index c18afd1320..aec45b1f91 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/EclipseLinkJpaMetamodelEntityInformationIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/EclipseLinkJpaMetamodelEntityInformationIntegrationTests.java @@ -35,7 +35,7 @@ * @author Greg Turnquist */ @ExtendWith(SpringExtension.class) -@ContextConfiguration({ "classpath:infrastructure.xml", "classpath:eclipselink.xml" }) +@ContextConfiguration("classpath:eclipselink-infrastructure.xml") class EclipseLinkJpaMetamodelEntityInformationIntegrationTests extends JpaMetamodelEntityInformationIntegrationTests { @Override diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/EntityManagerBeanDefinitionRegistrarPostProcessorIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/EntityManagerBeanDefinitionRegistrarPostProcessorIntegrationTests.java index 2ac1d8a501..5b7bef519c 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/EntityManagerBeanDefinitionRegistrarPostProcessorIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/EntityManagerBeanDefinitionRegistrarPostProcessorIntegrationTests.java @@ -56,7 +56,7 @@ void injectsEntityManagerIntoConstructors() { @Configuration @Import(EntityManagerInjectionTarget.class) - @ImportResource("classpath:infrastructure.xml") + @ImportResource("classpath:hibernate-infrastructure.xml") static class Config { @Autowired @Qualifier("entityManagerFactory") EntityManagerFactory emf; diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/HibernateJpaMetamodelEntityInformationIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/HibernateJpaMetamodelEntityInformationIntegrationTests.java index deffda2a29..abe5d87b87 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/HibernateJpaMetamodelEntityInformationIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/HibernateJpaMetamodelEntityInformationIntegrationTests.java @@ -28,7 +28,7 @@ * @author Greg Turnquist */ @ExtendWith(SpringExtension.class) -@ContextConfiguration("classpath:infrastructure.xml") +@ContextConfiguration("classpath:hibernate-infrastructure.xml") class HibernateJpaMetamodelEntityInformationIntegrationTests extends JpaMetamodelEntityInformationIntegrationTests { @Override diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/JavaConfigDefaultTransactionDisablingIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/JavaConfigDefaultTransactionDisablingIntegrationTests.java index 7d985c050d..057fe47bd4 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/JavaConfigDefaultTransactionDisablingIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/JavaConfigDefaultTransactionDisablingIntegrationTests.java @@ -34,6 +34,6 @@ class JavaConfigDefaultTransactionDisablingIntegrationTests extends DefaultTrans @Configuration @EnableJpaRepositories(basePackageClasses = UserRepository.class, enableDefaultTransactions = false) @EnableTransactionManagement - @ImportResource({ "classpath:infrastructure.xml", "classpath:tx-manager.xml" }) + @ImportResource({ "classpath:hibernate-infrastructure.xml", "classpath:tx-manager.xml" }) static class Config {} } diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/JpaRepositoryFactoryBeanEntityPathResolverIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/JpaRepositoryFactoryBeanEntityPathResolverIntegrationTests.java index eb30dbb634..aae2db4018 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/JpaRepositoryFactoryBeanEntityPathResolverIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/JpaRepositoryFactoryBeanEntityPathResolverIntegrationTests.java @@ -41,7 +41,7 @@ class JpaRepositoryFactoryBeanEntityPathResolverIntegrationTests { @Configuration - @ImportResource("classpath:infrastructure.xml") + @ImportResource("classpath:hibernate-infrastructure.xml") @EnableJpaRepositories(basePackageClasses = UserRepository.class, // includeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = UserRepository.class)) static class BaseConfig { diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/JpaRepositoryTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/JpaRepositoryTests.java index 535d8a4294..446d3b1568 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/JpaRepositoryTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/JpaRepositoryTests.java @@ -47,7 +47,7 @@ * @author Krzysztof Krason */ @ExtendWith(SpringExtension.class) -@ContextConfiguration({ "classpath:infrastructure.xml" }) +@ContextConfiguration("classpath:hibernate-infrastructure.xml") @Transactional class JpaRepositoryTests { diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/QuerydslIntegrationTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/QuerydslIntegrationTests.java index 4a59ea90a4..08db9fd7d8 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/QuerydslIntegrationTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/QuerydslIntegrationTests.java @@ -43,7 +43,7 @@ * @author Marcus Voltolim */ @ExtendWith(SpringExtension.class) -@ContextConfiguration({ "classpath:infrastructure.xml" }) +@ContextConfiguration("classpath:hibernate-infrastructure.xml") @Transactional class QuerydslIntegrationTests { diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/QuerydslJpaPredicateExecutorUnitTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/QuerydslJpaPredicateExecutorUnitTests.java index 8304430499..1669095a1f 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/QuerydslJpaPredicateExecutorUnitTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/QuerydslJpaPredicateExecutorUnitTests.java @@ -67,7 +67,7 @@ * @author Krzysztof Krason */ @ExtendWith(SpringExtension.class) -@ContextConfiguration({ "classpath:infrastructure.xml" }) +@ContextConfiguration("classpath:hibernate-infrastructure.xml") @Transactional class QuerydslJpaPredicateExecutorUnitTests { diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/QuerydslRepositorySupportTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/QuerydslRepositorySupportTests.java index 4e1e1d650a..9b6111f097 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/QuerydslRepositorySupportTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/QuerydslRepositorySupportTests.java @@ -41,7 +41,7 @@ * @author Krzysztof Krason */ @ExtendWith(SpringExtension.class) -@ContextConfiguration({ "classpath:infrastructure.xml" }) +@ContextConfiguration("classpath:hibernate-infrastructure.xml") @Transactional class QuerydslRepositorySupportTests { diff --git a/spring-data-jpa/src/test/resources/application-context.xml b/spring-data-jpa/src/test/resources/application-context.xml index bc6692f19c..dbdf5aa7bb 100644 --- a/spring-data-jpa/src/test/resources/application-context.xml +++ b/spring-data-jpa/src/test/resources/application-context.xml @@ -6,7 +6,7 @@ http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd"> - + diff --git a/spring-data-jpa/src/test/resources/auditing/auditing-bfpp-context.xml b/spring-data-jpa/src/test/resources/auditing/auditing-bfpp-context.xml index 955cbaa920..4ec4196509 100644 --- a/spring-data-jpa/src/test/resources/auditing/auditing-bfpp-context.xml +++ b/spring-data-jpa/src/test/resources/auditing/auditing-bfpp-context.xml @@ -7,7 +7,7 @@ - - + + diff --git a/spring-data-jpa/src/test/resources/auditing/auditing-entity-listener.xml b/spring-data-jpa/src/test/resources/auditing/auditing-entity-listener.xml index b0ddac33aa..f1d80c2bce 100644 --- a/spring-data-jpa/src/test/resources/auditing/auditing-entity-listener.xml +++ b/spring-data-jpa/src/test/resources/auditing/auditing-entity-listener.xml @@ -1,13 +1,11 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:jpa="http://www.springframework.org/schema/data/jpa" + xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/data/jpa https://www.springframework.org/schema/data/jpa/spring-jpa.xsd"> - + diff --git a/spring-data-jpa/src/test/resources/auditing/auditing-entity-with-embeddable-listener.xml b/spring-data-jpa/src/test/resources/auditing/auditing-entity-with-embeddable-listener.xml index d874d03e86..d0e3609781 100644 --- a/spring-data-jpa/src/test/resources/auditing/auditing-entity-with-embeddable-listener.xml +++ b/spring-data-jpa/src/test/resources/auditing/auditing-entity-with-embeddable-listener.xml @@ -2,12 +2,10 @@ + http://www.springframework.org/schema/data/jpa https://www.springframework.org/schema/data/jpa/spring-jpa.xsd"> - + diff --git a/spring-data-jpa/src/test/resources/auditing/auditing-namespace-context.xml b/spring-data-jpa/src/test/resources/auditing/auditing-namespace-context.xml index a9ad5d700b..dcaa8a3417 100644 --- a/spring-data-jpa/src/test/resources/auditing/auditing-namespace-context.xml +++ b/spring-data-jpa/src/test/resources/auditing/auditing-namespace-context.xml @@ -4,8 +4,8 @@ xmlns:jpa="http://www.springframework.org/schema/data/jpa" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/data/jpa https://www.springframework.org/schema/data/jpa/spring-jpa.xsd"> - - + + diff --git a/spring-data-jpa/src/test/resources/config/lookup-strategies-context.xml b/spring-data-jpa/src/test/resources/config/lookup-strategies-context.xml index a51321b190..05e7cb3e02 100644 --- a/spring-data-jpa/src/test/resources/config/lookup-strategies-context.xml +++ b/spring-data-jpa/src/test/resources/config/lookup-strategies-context.xml @@ -6,8 +6,8 @@ xsi:schemaLocation="http://www.springframework.org/schema/data/repository https://www.springframework.org/schema/data/repository/spring-repository.xsd http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/data/jpa https://www.springframework.org/schema/data/jpa/spring-jpa.xsd"> - - + + diff --git a/spring-data-jpa/src/test/resources/config/namespace-application-context-h2.xml b/spring-data-jpa/src/test/resources/config/namespace-application-context-h2.xml deleted file mode 100644 index 9cb3eab275..0000000000 --- a/spring-data-jpa/src/test/resources/config/namespace-application-context-h2.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - diff --git a/spring-data-jpa/src/test/resources/config/namespace-application-context.xml b/spring-data-jpa/src/test/resources/config/namespace-application-context.xml index b5c02d868d..540e2f304c 100644 --- a/spring-data-jpa/src/test/resources/config/namespace-application-context.xml +++ b/spring-data-jpa/src/test/resources/config/namespace-application-context.xml @@ -5,9 +5,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/data/jpa https://www.springframework.org/schema/data/jpa/spring-jpa.xsd"> - - - - - - - org.h2.Driver - jdbc:h2:mem:hades - sa - - create-tables - false - SEVERE - - - diff --git a/spring-data-jpa/src/test/resources/eclipselink-infrastructure.xml b/spring-data-jpa/src/test/resources/eclipselink-infrastructure.xml new file mode 100644 index 0000000000..de9a51b8d3 --- /dev/null +++ b/spring-data-jpa/src/test/resources/eclipselink-infrastructure.xml @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/spring-data-jpa/src/test/resources/eclipselink.xml b/spring-data-jpa/src/test/resources/eclipselink.xml index 1eec853095..7602462ef7 100644 --- a/spring-data-jpa/src/test/resources/eclipselink.xml +++ b/spring-data-jpa/src/test/resources/eclipselink.xml @@ -9,11 +9,6 @@ - org.hsqldb.jdbcDriver - jdbc:hsqldb:mem:hades - sa - - create-tables false SEVERE diff --git a/spring-data-jpa/src/test/resources/infrastructure-h2.xml b/spring-data-jpa/src/test/resources/h2.xml similarity index 56% rename from spring-data-jpa/src/test/resources/infrastructure-h2.xml rename to spring-data-jpa/src/test/resources/h2.xml index 723454c015..7df8a4a6c4 100644 --- a/spring-data-jpa/src/test/resources/infrastructure-h2.xml +++ b/spring-data-jpa/src/test/resources/h2.xml @@ -5,28 +5,11 @@ xsi:schemaLocation="http://www.springframework.org/schema/jdbc https://www.springframework.org/schema/jdbc/spring-jdbc.xsd http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> - - - - - - - - - - - - - - - diff --git a/spring-data-jpa/src/test/resources/hibernate-h2-infrastructure.xml b/spring-data-jpa/src/test/resources/hibernate-h2-infrastructure.xml new file mode 100644 index 0000000000..1944f0ad68 --- /dev/null +++ b/spring-data-jpa/src/test/resources/hibernate-h2-infrastructure.xml @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/spring-data-jpa/src/test/resources/hibernate-infrastructure.xml b/spring-data-jpa/src/test/resources/hibernate-infrastructure.xml new file mode 100644 index 0000000000..b2307bdd34 --- /dev/null +++ b/spring-data-jpa/src/test/resources/hibernate-infrastructure.xml @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/spring-data-jpa/src/test/resources/hsqldb.xml b/spring-data-jpa/src/test/resources/hsqldb.xml new file mode 100644 index 0000000000..11aa47450c --- /dev/null +++ b/spring-data-jpa/src/test/resources/hsqldb.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/spring-data-jpa/src/test/resources/infrastructure.xml b/spring-data-jpa/src/test/resources/infrastructure.xml index 10877ba132..5fa4f4ab75 100644 --- a/spring-data-jpa/src/test/resources/infrastructure.xml +++ b/spring-data-jpa/src/test/resources/infrastructure.xml @@ -1,11 +1,7 @@ - - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> @@ -15,20 +11,10 @@ - - - - - - - - - - diff --git a/spring-data-jpa/src/test/resources/multiple-entity-manager-integration-context.xml b/spring-data-jpa/src/test/resources/multiple-entity-manager-integration-context.xml index 93c9fa8669..a713938ad1 100644 --- a/spring-data-jpa/src/test/resources/multiple-entity-manager-integration-context.xml +++ b/spring-data-jpa/src/test/resources/multiple-entity-manager-integration-context.xml @@ -9,7 +9,7 @@ http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/data/jpa https://www.springframework.org/schema/data/jpa/spring-jpa.xsd"> - + - +