Skip to content

Commit 50ac305

Browse files
committed
Adopt to deprecation removals in Commons.
Closes #3683
1 parent c5cc96f commit 50ac305

File tree

7 files changed

+23
-69
lines changed

7 files changed

+23
-69
lines changed

spring-data-envers/src/main/java/org/springframework/data/envers/repository/support/EnversRevisionRepositoryFactoryBean.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
*/
1616
package org.springframework.data.envers.repository.support;
1717

18-
import java.util.Optional;
19-
2018
import jakarta.persistence.EntityManager;
2119

20+
import java.util.Optional;
21+
2222
import org.hibernate.envers.DefaultRevisionEntity;
23+
2324
import org.springframework.beans.factory.FactoryBean;
2425
import org.springframework.data.jpa.repository.support.JpaRepositoryFactory;
2526
import org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean;
@@ -94,7 +95,7 @@ public RevisionRepositoryFactory(EntityManager entityManager, Class<?> revisionE
9495
@Override
9596
protected RepositoryFragments getRepositoryFragments(RepositoryMetadata metadata) {
9697

97-
Object fragmentImplementation = getTargetRepositoryViaReflection( //
98+
Object fragmentImplementation = instantiateClass( //
9899
EnversRevisionRepositoryImpl.class, //
99100
getEntityInformation(metadata.getDomainType()), //
100101
revisionEntityInformation, //

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaParameters.java

-19
Original file line numberDiff line numberDiff line change
@@ -90,25 +90,6 @@ public static class JpaParameter extends Parameter {
9090
private final @Nullable Temporal annotation;
9191
private @Nullable TemporalType temporalType;
9292

93-
/**
94-
* Creates a new {@link JpaParameter}.
95-
*
96-
* @param parameter must not be {@literal null}.
97-
* @deprecated since 3.2.1
98-
*/
99-
@Deprecated(since = "3.2.1", forRemoval = true)
100-
protected JpaParameter(MethodParameter parameter) {
101-
102-
super(parameter);
103-
104-
this.annotation = parameter.getParameterAnnotation(Temporal.class);
105-
this.temporalType = null;
106-
if (!isDateParameter() && hasTemporalParamAnnotation()) {
107-
throw new IllegalArgumentException(
108-
Temporal.class.getSimpleName() + " annotation is only allowed on Date parameter");
109-
}
110-
}
111-
11293
/**
11394
* Creates a new {@link JpaParameter}.
11495
*

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryLookupStrategy.java

-25
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.apache.commons.logging.Log;
2323
import org.apache.commons.logging.LogFactory;
2424

25-
import org.springframework.core.env.StandardEnvironment;
2625
import org.springframework.data.jpa.repository.Query;
2726
import org.springframework.data.jpa.repository.QueryRewriter;
2827
import org.springframework.data.projection.ProjectionFactory;
@@ -31,8 +30,6 @@
3130
import org.springframework.data.repository.query.QueryLookupStrategy;
3231
import org.springframework.data.repository.query.QueryLookupStrategy.Key;
3332
import org.springframework.data.repository.query.QueryMethod;
34-
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
35-
import org.springframework.data.repository.query.QueryMethodValueEvaluationContextAccessor;
3633
import org.springframework.data.repository.query.RepositoryQuery;
3734
import org.springframework.data.repository.query.ValueExpressionDelegate;
3835
import org.springframework.lang.Nullable;
@@ -263,28 +260,6 @@ protected RepositoryQuery resolveQuery(JpaQueryMethod method, QueryRewriter quer
263260
}
264261
}
265262

266-
/**
267-
* Creates a {@link QueryLookupStrategy} for the given {@link EntityManager} and {@link Key}.
268-
*
269-
* @param em must not be {@literal null}.
270-
* @param queryMethodFactory must not be {@literal null}.
271-
* @param key may be {@literal null}.
272-
* @param evaluationContextProvider must not be {@literal null}.
273-
* @param escape must not be {@literal null}.
274-
* @deprecated since 3.4, use
275-
* {@link #create(EntityManager, JpaQueryMethodFactory, Key, ValueExpressionDelegate, QueryRewriterProvider, EscapeCharacter)}
276-
* instead.
277-
*/
278-
@Deprecated(since = "3.4")
279-
public static QueryLookupStrategy create(EntityManager em, JpaQueryMethodFactory queryMethodFactory,
280-
@Nullable Key key, QueryMethodEvaluationContextProvider evaluationContextProvider,
281-
QueryRewriterProvider queryRewriterProvider, EscapeCharacter escape) {
282-
return create(em, queryMethodFactory, key,
283-
new ValueExpressionDelegate(new QueryMethodValueEvaluationContextAccessor(new StandardEnvironment(),
284-
evaluationContextProvider.getEvaluationContextProvider()), ValueExpressionDelegate.create()),
285-
queryRewriterProvider, escape);
286-
}
287-
288263
/**
289264
* Creates a {@link QueryLookupStrategy} for the given {@link EntityManager} and {@link Key}.
290265
*

spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/JavaConfigUserRepositoryTests.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
*/
1616
package org.springframework.data.jpa.repository;
1717

18-
import java.io.IOException;
19-
import java.util.Collections;
20-
2118
import jakarta.persistence.EntityManager;
2219
import jakarta.persistence.PersistenceContext;
2320

21+
import java.io.IOException;
22+
import java.util.Collections;
23+
2424
import org.assertj.core.api.Assertions;
2525
import org.junit.jupiter.api.Test;
26+
2627
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
2728
import org.springframework.beans.factory.annotation.Autowired;
2829
import org.springframework.beans.factory.config.PropertiesFactoryBean;
@@ -42,8 +43,7 @@
4243
import org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean;
4344
import org.springframework.data.repository.core.NamedQueries;
4445
import org.springframework.data.repository.core.support.PropertiesBasedNamedQueries;
45-
import org.springframework.data.repository.query.ExtensionAwareQueryMethodEvaluationContextProvider;
46-
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
46+
import org.springframework.data.spel.ExtensionAwareEvaluationContextProvider;
4747
import org.springframework.data.spel.spi.EvaluationContextExtension;
4848
import org.springframework.test.context.ContextConfiguration;
4949
import org.springframework.test.context.support.AnnotationConfigContextLoader;
@@ -72,7 +72,7 @@ public EvaluationContextExtension sampleEvaluationContextExtension() {
7272
@Bean
7373
public UserRepository userRepository() throws Exception {
7474

75-
QueryMethodEvaluationContextProvider evaluationContextProvider = new ExtensionAwareQueryMethodEvaluationContextProvider(
75+
ExtensionAwareEvaluationContextProvider evaluationContextProvider = new ExtensionAwareEvaluationContextProvider(
7676
applicationContext);
7777

7878
JpaRepositoryFactoryBean<UserRepository, User, Integer> factory = new JpaRepositoryFactoryBean<>(

spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpaQueryLookupStrategyUnitTests.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.mockito.junit.jupiter.MockitoExtension;
3434
import org.mockito.junit.jupiter.MockitoSettings;
3535
import org.mockito.quality.Strictness;
36+
3637
import org.springframework.beans.factory.BeanFactory;
3738
import org.springframework.data.domain.Page;
3839
import org.springframework.data.domain.Pageable;
@@ -47,8 +48,8 @@
4748
import org.springframework.data.repository.core.support.DefaultRepositoryMetadata;
4849
import org.springframework.data.repository.query.QueryLookupStrategy;
4950
import org.springframework.data.repository.query.QueryLookupStrategy.Key;
50-
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
5151
import org.springframework.data.repository.query.RepositoryQuery;
52+
import org.springframework.data.repository.query.ValueExpressionDelegate;
5253

5354
/**
5455
* Unit tests for {@link JpaQueryLookupStrategy}.
@@ -63,7 +64,7 @@
6364
@MockitoSettings(strictness = Strictness.LENIENT)
6465
class JpaQueryLookupStrategyUnitTests {
6566

66-
private static final QueryMethodEvaluationContextProvider EVALUATION_CONTEXT_PROVIDER = QueryMethodEvaluationContextProvider.DEFAULT;
67+
private static final ValueExpressionDelegate VALUE_EXPRESSION_DELEGATE = ValueExpressionDelegate.create();
6768

6869
@Mock EntityManager em;
6970
@Mock EntityManagerFactory emf;
@@ -89,7 +90,7 @@ void setUp() {
8990
void invalidAnnotatedQueryCausesException() throws Exception {
9091

9192
QueryLookupStrategy strategy = JpaQueryLookupStrategy.create(em, queryMethodFactory, Key.CREATE_IF_NOT_FOUND,
92-
EVALUATION_CONTEXT_PROVIDER, new BeanFactoryQueryRewriterProvider(beanFactory), EscapeCharacter.DEFAULT);
93+
VALUE_EXPRESSION_DELEGATE, new BeanFactoryQueryRewriterProvider(beanFactory), EscapeCharacter.DEFAULT);
9394
Method method = UserRepository.class.getMethod("findByFoo", String.class);
9495
RepositoryMetadata metadata = new DefaultRepositoryMetadata(UserRepository.class);
9596

@@ -101,7 +102,7 @@ void invalidAnnotatedQueryCausesException() throws Exception {
101102
void considersNamedCountQuery() throws Exception {
102103

103104
QueryLookupStrategy strategy = JpaQueryLookupStrategy.create(em, queryMethodFactory, Key.CREATE_IF_NOT_FOUND,
104-
EVALUATION_CONTEXT_PROVIDER, new BeanFactoryQueryRewriterProvider(beanFactory), EscapeCharacter.DEFAULT);
105+
VALUE_EXPRESSION_DELEGATE, new BeanFactoryQueryRewriterProvider(beanFactory), EscapeCharacter.DEFAULT);
105106

106107
when(namedQueries.hasQuery("foo.count")).thenReturn(true);
107108
when(namedQueries.getQuery("foo.count")).thenReturn("select count(foo) from Foo foo");
@@ -123,7 +124,7 @@ void considersNamedCountQuery() throws Exception {
123124
void considersNamedCountOnStringQueryQuery() throws Exception {
124125

125126
QueryLookupStrategy strategy = JpaQueryLookupStrategy.create(em, queryMethodFactory, Key.CREATE_IF_NOT_FOUND,
126-
EVALUATION_CONTEXT_PROVIDER, new BeanFactoryQueryRewriterProvider(beanFactory), EscapeCharacter.DEFAULT);
127+
VALUE_EXPRESSION_DELEGATE, new BeanFactoryQueryRewriterProvider(beanFactory), EscapeCharacter.DEFAULT);
127128

128129
when(namedQueries.hasQuery("foo.count")).thenReturn(true);
129130
when(namedQueries.getQuery("foo.count")).thenReturn("select count(foo) from Foo foo");
@@ -142,7 +143,7 @@ void considersNamedCountOnStringQueryQuery() throws Exception {
142143
void prefersDeclaredQuery() throws Exception {
143144

144145
QueryLookupStrategy strategy = JpaQueryLookupStrategy.create(em, queryMethodFactory, Key.CREATE_IF_NOT_FOUND,
145-
EVALUATION_CONTEXT_PROVIDER, new BeanFactoryQueryRewriterProvider(beanFactory), EscapeCharacter.DEFAULT);
146+
VALUE_EXPRESSION_DELEGATE, new BeanFactoryQueryRewriterProvider(beanFactory), EscapeCharacter.DEFAULT);
146147
Method method = UserRepository.class.getMethod("annotatedQueryWithQueryAndQueryName");
147148
RepositoryMetadata metadata = new DefaultRepositoryMetadata(UserRepository.class);
148149

@@ -155,7 +156,7 @@ void prefersDeclaredQuery() throws Exception {
155156
void namedQueryWithSortShouldThrowIllegalStateException() throws NoSuchMethodException {
156157

157158
QueryLookupStrategy strategy = JpaQueryLookupStrategy.create(em, queryMethodFactory, Key.CREATE_IF_NOT_FOUND,
158-
EVALUATION_CONTEXT_PROVIDER, new BeanFactoryQueryRewriterProvider(beanFactory), EscapeCharacter.DEFAULT);
159+
VALUE_EXPRESSION_DELEGATE, new BeanFactoryQueryRewriterProvider(beanFactory), EscapeCharacter.DEFAULT);
159160

160161
Method method = UserRepository.class.getMethod("customNamedQuery", String.class, Sort.class);
161162
RepositoryMetadata metadata = new DefaultRepositoryMetadata(UserRepository.class);
@@ -180,7 +181,7 @@ void noQueryShouldNotBeInvoked() {
180181
void customQueryWithQuestionMarksShouldWork() throws NoSuchMethodException {
181182

182183
QueryLookupStrategy strategy = JpaQueryLookupStrategy.create(em, queryMethodFactory, Key.CREATE_IF_NOT_FOUND,
183-
EVALUATION_CONTEXT_PROVIDER, new BeanFactoryQueryRewriterProvider(beanFactory), EscapeCharacter.DEFAULT);
184+
VALUE_EXPRESSION_DELEGATE, new BeanFactoryQueryRewriterProvider(beanFactory), EscapeCharacter.DEFAULT);
184185

185186
Method namedMethod = UserRepository.class.getMethod("customQueryWithQuestionMarksAndNamedParam", String.class);
186187
RepositoryMetadata namedMetadata = new DefaultRepositoryMetadata(UserRepository.class);

spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/QuerydslJpaPredicateExecutorUnitTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ void findBySpecificationWithSortByQueryDslOrderSpecifierWithQPageRequestAndQSort
213213
QUser user = QUser.user;
214214

215215
Page<User> page = predicateExecutor.findAll(user.firstname.isNotNull(),
216-
new QPageRequest(0, 10, new QSort(user.firstname.asc())));
216+
QPageRequest.of(0, 10, new QSort(user.firstname.asc())));
217217

218218
assertThat(page.getContent()).containsExactly(carter, dave, oliver);
219219
}
@@ -224,7 +224,7 @@ void findBySpecificationWithSortByQueryDslOrderSpecifierWithQPageRequest() {
224224
QUser user = QUser.user;
225225

226226
Page<User> page = predicateExecutor.findAll(user.firstname.isNotNull(),
227-
new QPageRequest(0, 10, user.firstname.asc()));
227+
QPageRequest.of(0, 10, user.firstname.asc()));
228228

229229
assertThat(page.getContent()).containsExactly(carter, dave, oliver);
230230
}
@@ -238,7 +238,7 @@ void findBySpecificationWithSortByQueryDslOrderSpecifierForAssociationShouldGene
238238
QUser user = QUser.user;
239239

240240
Page<User> page = predicateExecutor.findAll(user.firstname.isNotNull(),
241-
new QPageRequest(0, 10, user.manager.firstname.asc()));
241+
QPageRequest.of(0, 10, user.manager.firstname.asc()));
242242

243243
assertThat(page.getContent()).containsExactly(carter, dave, oliver);
244244
}

spring-data-jpa/src/test/resources/application-context.xml

+1-5
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@
2525
</constructor-arg>
2626
</bean>
2727
</property>
28-
<property name="evaluationContextProvider" ref="expressionEvaluationContextProvider"/>
2928
</bean>
30-
29+
3130
<bean id="roleDao" class="org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean">
3231
<constructor-arg value="org.springframework.data.jpa.repository.sample.RoleRepository" />
33-
<property name="evaluationContextProvider" ref="expressionEvaluationContextProvider"/>
3432
</bean>
3533

3634
<!-- Necessary to get the entity manager injected into the factory bean -->
@@ -39,8 +37,6 @@
3937
<!-- Adds transparent exception translation to the DAOs -->
4038
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
4139

42-
<bean id="expressionEvaluationContextProvider" class="org.springframework.data.repository.query.ExtensionAwareQueryMethodEvaluationContextProvider" autowire="constructor" />
43-
4440
<bean class="org.springframework.data.jpa.repository.support.EntityManagerBeanDefinitionRegistrarPostProcessor" />
4541

4642
<bean class="org.springframework.data.jpa.repository.GreetingsFrom" name="greetingsFrom" />

0 commit comments

Comments
 (0)