[英]Spring Boot QueryDsl java.lang.UnsupportedOperationException
//Page<Board> result = (Page<Board>) repo.findAll();
Page<Board> result = repo.findAll(builder, pageable);
System.out.println("넘어오긴했음");
System.out.println("PAGE SIZE : "+result.getSize());
System.out.println("TOTAL PAGES : " + result.getTotalPages());
System.out.println("TOTAL COUNT : "+ result.getTotalElements());
System.out.println("NEXT : "+result.nextPageable());
//List<Board> list =new ArrayList<Board>(result.getContent());
//list.forEach(b -> System.out.println(b));
it returns java.lang.UnsupportedOperationException它返回 java.lang.UnsupportedOperationException
how can i get Page by use findall method?如何使用 findall 方法获取 Page?
most said edit here最常说的编辑在这里
List<Board> list = result.getContent();
to至
List<Board> list =new ArrayList<Board>(result.getContent());
but my problem is occured但我的问题发生了
Page<Board> result = repo.findAll(builder, pageable);
here is trace这是痕迹
java.lang.UnsupportedOperationException
at java.util.Collections$UnmodifiableMap.put(Collections.java:1459)
at com.querydsl.jpa.JPQLSerializer.visitConstant(JPQLSerializer.java:327)
at com.querydsl.core.support.SerializerBase.visit(SerializerBase.java:221)
at com.querydsl.core.support.SerializerBase.visit(SerializerBase.java:36)
at com.querydsl.core.types.ConstantImpl.accept(ConstantImpl.java:140)
at
com.querydsl.core.support.SerializerBase.handle(SerializerBase.java:122)
at com.querydsl.core.support.SerializerBase.visitOperation(SerializerBase.java:301)
at com.querydsl.jpa.JPQLSerializer.visitOperation(JPQLSerializer.java:422)
at com.querydsl.core.support.SerializerBase.visit(SerializerBase.java:262)
at com.querydsl.core.support.SerializerBase.visit(SerializerBase.java:36)
at com.querydsl.core.types.OperationImpl.accept(OperationImpl.java:83)
at com.querydsl.core.support.SerializerBase.handle(SerializerBase.java:122)
at com.querydsl.core.support.SerializerBase.visitOperation(SerializerBase.java:298)
I think findAll
can accept a Pageable
parameter,我认为
findAll
可以接受Pageable
参数,
Page<Board> findAll(Pageable pageable);
This is not related to QueryDSL
.这与
QueryDSL
。
Check my samples of Spring Data JPA/QueryDSL (You should update to the latest Spring yourself).检查我的 Spring 数据 JPA/QueryDSL 样本(您应该自己更新到最新的 Spring)。
In PagingAndSortingRepository findAll
method allow only Pageable
parameter在 PagingAndSortingRepository 中的
findAll
方法只允许Pageable
参数
public interface PagingAndSortingRepository<T, ID> extends CrudRepository<T, ID> {
Iterable<T> findAll(Sort var1);
Page<T> findAll(Pageable var1);
}
so if you want findAll method return Page
through querydsl
with builder因此,如果您希望 findAll 方法通过带有构建器的
querydsl
返回Page
then extend CustomRepository like this custom-implementation-of-intermediate-repository-in-spring-data然后扩展 CustomRepository 像这样custom-implementation-of-intermediate-repository-in-spring-data
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.