Skip to content

Commit 7c09a87

Browse files
Auri Munozgsmet
authored andcommitted
Include several fixes related to #40344
(cherry picked from commit c62ce05)
1 parent 921d160 commit 7c09a87

File tree

14 files changed

+661
-121
lines changed

14 files changed

+661
-121
lines changed

bom/application/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
<hibernate-quarkus-local-cache.version>0.3.0</hibernate-quarkus-local-cache.version>
173173
<flapdoodle.mongo.version>4.14.0</flapdoodle.mongo.version>
174174
<quarkus-spring-api.version>6.1.SP2</quarkus-spring-api.version>
175-
<quarkus-spring-data-api.version>3.2.SP1</quarkus-spring-data-api.version>
175+
<quarkus-spring-data-api.version>3.2.SP2</quarkus-spring-data-api.version>
176176
<quarkus-spring-security-api.version>6.2</quarkus-spring-security-api.version>
177177
<quarkus-spring-boot-api.version>3.2</quarkus-spring-boot-api.version>
178178
<mockito.version>5.12.0</mockito.version>

extensions/spring-data-rest/deployment/src/main/java/io/quarkus/spring/data/rest/deployment/RepositoryMethodsImplementor.java

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ public class RepositoryMethodsImplementor implements ResourceMethodsImplementor
5353
public static final MethodDescriptor LIST_PAGED = ofMethod(PagingAndSortingRepository.class, "findAll",
5454
org.springframework.data.domain.Page.class, Pageable.class);
5555

56-
//ListPagingAndSortingRepository
57-
public static final MethodDescriptor LIST_SORTED = ofMethod(ListPagingAndSortingRepository.class, "findAll",
58-
List.class, org.springframework.data.domain.Sort.class);
59-
6056
private static final Class<?> PANACHE_PAGE = io.quarkus.panache.common.Page.class;
6157

6258
private static final Class<?> PANACHE_SORT = io.quarkus.panache.common.Sort.class;
@@ -83,34 +79,37 @@ public RepositoryMethodsImplementor(IndexView index, EntityClassHelper entityCla
8379
}
8480

8581
// CrudRepository Iterable<T> findAll();
86-
public void implementListIterable(ClassCreator classCreator, String repositoryInterfaceName) {
82+
public void implementIterable(ClassCreator classCreator, String repositoryInterfaceName) {
8783
if (entityClassHelper.isCrudRepository(repositoryInterfaceName)
8884
&& !entityClassHelper.isPagingAndSortingRepository(repositoryInterfaceName)) {
8985
MethodCreator methodCreator = classCreator.getMethodCreator("list", List.class, Page.class, Sort.class,
9086
String.class, Map.class);
9187
ResultHandle repository = getRepositoryInstance(methodCreator, repositoryInterfaceName);
9288
ResultHandle result = methodCreator.invokeInterfaceMethod(LIST_ITERABLE, repository);
9389
methodCreator.returnValue(result);
94-
LOGGER.infof("Method code: %s ", methodCreator.getMethodDescriptor().toString());
90+
LOGGER.debugf("Method code: %s ", methodCreator.getMethodDescriptor().toString());
9591
methodCreator.close();
9692
}
9793
}
9894

9995
//ListCrudRepository List<T> findAll();
10096
public void implementList(ClassCreator classCreator, String repositoryInterfaceName) {
101-
if (entityClassHelper.isListCrudRepository(repositoryInterfaceName)) {
97+
if (entityClassHelper.isListCrudRepository(repositoryInterfaceName)
98+
&& !entityClassHelper.isListPagingAndSortingRepository(repositoryInterfaceName)) {
10299
MethodCreator methodCreator = classCreator.getMethodCreator("list", List.class, Page.class, Sort.class,
103100
String.class, Map.class);
104101
ResultHandle repository = getRepositoryInstance(methodCreator, repositoryInterfaceName);
105102
ResultHandle result = methodCreator.invokeInterfaceMethod(LIST, repository);
106103
methodCreator.returnValue(result);
107-
LOGGER.infof("Method code: %s ", methodCreator.toString());
104+
LOGGER.debugf("Method code: %s ", methodCreator.toString());
108105
methodCreator.close();
109106
}
110107
}
111108

112109
// PagingAndSortingRepository Page<T> findAll(Pageable pageable);
113-
public void implementListPaged(ClassCreator classCreator, String repositoryInterfaceName) {
110+
// PagingAndSortingRepository Iterable<T> findAll(Pageable pageable);
111+
// ListPagingAndSortingRepository List<T> findAll(Sort sort);
112+
public void implementPagedList(ClassCreator classCreator, String repositoryInterfaceName) {
114113
if (entityClassHelper.isPagingAndSortingRepository(repositoryInterfaceName)) {
115114
MethodCreator methodCreator = classCreator.getMethodCreator("list", List.class, Page.class,
116115
io.quarkus.panache.common.Sort.class, String.class, Map.class);
@@ -124,26 +123,7 @@ public void implementListPaged(ClassCreator classCreator, String repositoryInter
124123
ofMethod(org.springframework.data.domain.Page.class, "getContent", List.class), resultPage);
125124

126125
methodCreator.returnValue(result);
127-
LOGGER.infof("Method code: %s ", methodCreator.toString());
128-
methodCreator.close();
129-
}
130-
}
131-
132-
//ListPagingAndSortingRepository List<T> findAll(Sort sort);
133-
public void implementListSort(ClassCreator classCreator, String repositoryInterfaceName) {
134-
if (entityClassHelper.isListPagingAndSortingRepository(repositoryInterfaceName)) {
135-
MethodCreator methodCreator = classCreator.getMethodCreator("list", List.class, Page.class,
136-
io.quarkus.panache.common.Sort.class, String.class, Map.class);
137-
ResultHandle page = methodCreator.getMethodParam(0);
138-
ResultHandle sort = methodCreator.getMethodParam(1);
139-
ResultHandle pageable = toPageable(methodCreator, page, sort);
140-
ResultHandle repository = getRepositoryInstance(methodCreator, repositoryInterfaceName);
141-
ResultHandle resultPage = methodCreator.invokeInterfaceMethod(LIST_SORTED, repository, pageable);
142-
ResultHandle result = methodCreator.invokeInterfaceMethod(
143-
ofMethod(org.springframework.data.domain.Page.class, "getContent", List.class), resultPage);
144-
145-
methodCreator.returnValue(result);
146-
LOGGER.infof("Method code: %s ", methodCreator.toString());
126+
LOGGER.debugf("Method code: %s ", methodCreator.toString());
147127
methodCreator.close();
148128
}
149129
}
@@ -163,7 +143,7 @@ public void implementListPageCount(ClassCreator classCreator, String repositoryI
163143
} else {
164144
methodCreator.throwException(RuntimeException.class, "Method not implemented");
165145
}
166-
LOGGER.infof("Method code: %s ", methodCreator.toString());
146+
LOGGER.debugf("Method code: %s ", methodCreator.toString());
167147
methodCreator.close();
168148
}
169149

@@ -175,7 +155,7 @@ public void implementListById(ClassCreator classCreator, String repositoryInterf
175155
ResultHandle repository = getRepositoryInstance(methodCreator, repositoryInterfaceName);
176156
ResultHandle result = methodCreator.invokeInterfaceMethod(LIST_BY_ID, repository, ids);
177157
methodCreator.returnValue(result);
178-
LOGGER.infof("Method code: %s ", methodCreator.toString());
158+
LOGGER.debugf("Method code: %s ", methodCreator.toString());
179159
methodCreator.close();
180160
}
181161
}
@@ -191,7 +171,7 @@ public void implementGet(ClassCreator classCreator, String repositoryInterfaceNa
191171
} else {
192172
methodCreator.throwException(RuntimeException.class, "Method not implemented");
193173
}
194-
LOGGER.infof("Method code: %s ", methodCreator.toString());
174+
LOGGER.debugf("Method code: %s ", methodCreator.toString());
195175
methodCreator.close();
196176
}
197177

@@ -208,7 +188,7 @@ public void implementAdd(ClassCreator classCreator, String repositoryInterfaceNa
208188
methodCreator.throwException(RuntimeException.class, "Method not implemented");
209189

210190
}
211-
LOGGER.infof("Method code: %s ", methodCreator.toString());
191+
LOGGER.debugf("Method code: %s ", methodCreator.toString());
212192
methodCreator.close();
213193
}
214194

@@ -223,7 +203,7 @@ public void implementAddList(ClassCreator classCreator, String repositoryInterfa
223203
} else {
224204
methodCreator.throwException(RuntimeException.class, "Method not implemented");
225205
}
226-
LOGGER.infof("Method code: %s ", methodCreator.toString());
206+
LOGGER.debugf("Method code: %s ", methodCreator.toString());
227207
methodCreator.close();
228208
}
229209

@@ -240,7 +220,7 @@ public void implementUpdate(ClassCreator classCreator, String repositoryInterfac
240220
} else {
241221
methodCreator.throwException(RuntimeException.class, "Method not implemented");
242222
}
243-
LOGGER.infof("Method code: %s ", methodCreator.toString());
223+
LOGGER.debugf("Method code: %s ", methodCreator.toString());
244224
methodCreator.close();
245225
}
246226

@@ -261,7 +241,7 @@ public void implementDelete(ClassCreator classCreator, String repositoryInterfac
261241
} else {
262242
methodCreator.throwException(RuntimeException.class, "Method not implemented");
263243
}
264-
LOGGER.infof("Method code: %s ", methodCreator.toString());
244+
LOGGER.debugf("Method code: %s ", methodCreator.toString());
265245
methodCreator.close();
266246
}
267247

extensions/spring-data-rest/deployment/src/main/java/io/quarkus/spring/data/rest/deployment/RepositoryPropertiesProvider.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import static io.quarkus.spring.data.rest.deployment.RepositoryMethodsImplementor.LIST;
77
import static io.quarkus.spring.data.rest.deployment.RepositoryMethodsImplementor.LIST_ITERABLE;
88
import static io.quarkus.spring.data.rest.deployment.RepositoryMethodsImplementor.LIST_PAGED;
9-
import static io.quarkus.spring.data.rest.deployment.RepositoryMethodsImplementor.LIST_SORTED;
109
import static io.quarkus.spring.data.rest.deployment.RepositoryMethodsImplementor.SAVE_LIST;
1110
import static io.quarkus.spring.data.rest.deployment.RepositoryMethodsImplementor.UPDATE;
1211

@@ -34,8 +33,6 @@ protected Map<String, Predicate<MethodInfo>> getMethodPredicates() {
3433
methodPredicates.put("listPaged", methodInfo -> methodInfo.name().equals(LIST_PAGED.getName())
3534
&& methodInfo.parametersCount() == 1
3635
&& methodInfo.parameterType(0).name().equals(PAGEABLE));
37-
methodPredicates.put("listSorted",
38-
methodInfo -> methodInfo.name().equals(LIST_SORTED.getName()) && methodInfo.parameterTypes().isEmpty());
3936
methodPredicates.put("addAll", methodInfo -> methodInfo.name().equals(SAVE_LIST.getName()));
4037
methodPredicates.put("get", methodInfo -> methodInfo.name().equals(GET.getName()));
4138
methodPredicates.put("add", methodInfo -> methodInfo.name().equals(ADD.getName()));

extensions/spring-data-rest/deployment/src/main/java/io/quarkus/spring/data/rest/deployment/ResourceImplementor.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ public String implement(ClassOutput classOutput, String resourceType, String ent
3333
.build();
3434

3535
classCreator.addAnnotation(ApplicationScoped.class);
36-
methodsImplementor.implementListIterable(classCreator, resourceType);
36+
methodsImplementor.implementIterable(classCreator, resourceType);
3737
methodsImplementor.implementList(classCreator, resourceType);
38-
methodsImplementor.implementListSort(classCreator, resourceType);
39-
methodsImplementor.implementListPaged(classCreator, resourceType);
38+
methodsImplementor.implementPagedList(classCreator, resourceType);
4039
methodsImplementor.implementAddList(classCreator, resourceType);
4140
methodsImplementor.implementListById(classCreator, resourceType);
4241
methodsImplementor.implementListPageCount(classCreator, resourceType);

extensions/spring-data-rest/deployment/src/main/java/io/quarkus/spring/data/rest/deployment/ResourceMethodsImplementor.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,14 @@ public interface ResourceMethodsImplementor {
1515

1616
void implementList(ClassCreator classCreator, String repositoryInterface);
1717

18-
void implementListIterable(ClassCreator classCreator, String repositoryInterface);
18+
void implementIterable(ClassCreator classCreator, String repositoryInterface);
1919

20-
void implementListPaged(ClassCreator classCreator, String repositoryInterface);
20+
void implementPagedList(ClassCreator classCreator, String repositoryInterface);
2121

2222
void implementListPageCount(ClassCreator classCreator, String repositoryInterface);
2323

2424
void implementListById(ClassCreator classCreator, String repositoryInterface);
2525

26-
public void implementListSort(ClassCreator classCreator, String repositoryInterface);
27-
2826
void implementGet(ClassCreator classCreator, String repositoryInterface);
2927

3028
void implementAdd(ClassCreator classCreator, String repositoryInterface);

extensions/spring-data-rest/deployment/src/main/java/io/quarkus/spring/data/rest/deployment/SpringDataRestProcessor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ private void implementResources(Capabilities capabilities,
111111
BuildProducer<UnremovableBeanBuildItem> unremovableBeansProducer,
112112
ResourceMethodsImplementor methodsImplementor,
113113
IndexView index,
114-
// ResourcePropertiesProvider propertiesProvider,
115114
List<ClassInfo> repositoriesToImplement) {
116115
ClassOutput classOutput = new GeneratedBeanGizmoAdaptor(implementationsProducer);
117116
ResourceImplementor resourceImplementor = new ResourceImplementor(methodsImplementor);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package io.quarkus.spring.data.rest;
2+
3+
import org.springframework.data.jpa.repository.JpaRepository;
4+
5+
import io.quarkus.spring.data.rest.paged.Record;
6+
7+
public interface JpaRecordsRepository extends JpaRepository<Record, Long> {
8+
}

0 commit comments

Comments
 (0)