Questions tagged [pageable]
104 questions
1
vote
0 answers
Create a Pagination by ArrayList
I basically need to create an ordered pagination through a list of objects.
I ended up creating a method that returns the pagination, although the ordering is still not working, I would like to know if there is any other better way that is, i'm…

Diogo Zucchi
- 13
- 3
1
vote
1 answer
Spring - Can't set Pageable to less than total result size
I have a weird situation where if I set the page size to less than the total size of the results, it errors out.
In my repo, have a giant query enclosed in a WITH to keep things simple, so paging should happen there (I also renamed some fields…

Mankind1023
- 7,198
- 16
- 56
- 86
1
vote
2 answers
Spring - get a page of entity with lazy elements loaded
I'm very new to Spring.
I'm trying to get a Page to return that to my front end.
The AppUser has a lazy association with Role entity.
I'm getting a failed to lazily initialize a collection of role error.
Did a lot of research but I do not get the…

GaetanK
- 11
- 2
1
vote
1 answer
How to only allow specific fields to sort by in a Spring Data JPA Repository Pageable?
Using a Pageable parameter in a Spring Data JPA Repository allows for specifying fields to sort by like: PageRequest.of(0, 50, Sort.by("field1", "field2")), which would sort by field1 and field2 ascending.
It works by appending an ORDER BY clause…

dukethrash
- 1,449
- 4
- 15
- 25
1
vote
1 answer
How to sort by ManyToOne list in Pageable without duplicates?
I recently ran into this problem. I have a product that has a list of values in relation to volume. Example: enter image description here
Entities :
public class Price implements Serializable, Comparable {
@Id
…

SnejOK
- 75
- 7
1
vote
2 answers
Example of spring using Pageable, Example and Sort accessing a JPA repository
I searched everywhere for an example of a Spring piece of code using simultaneously these 3 JPA concepts, very important when querying :
filtering - using Example, ExampleMatcher
paging - using Pageable (or similar)
sorting - using Sort
So far…

MS13
- 327
- 5
- 16
1
vote
0 answers
Spring Boot Pagination is not working with custom DTO list
I am stuck with integrating pagination in Spring boot project.
Service Impl class
@Override
public Page generateOnlineBuyProductReport(String fromDate, String toDate, int pageNum, String sortField, String sortDir) {
…

Thilina Rubasingha
- 1,049
- 1
- 9
- 17
1
vote
0 answers
Proper way to use Pageable sorting with nested objects when sending requests from frontend to backend?
I have many tables with sortable headers in the frontend. When any of them is clicked, a request similar to
http://localhost:8080/api/v1/items/?page=0&size=10&sort=item.type.name,asc&itemId=4
is sent to the backend where it gets automatically…

lisymcaydnlb
- 150
- 2
- 12
1
vote
1 answer
Spring Data JDBC - Pageable on custom Query
On my Project I have a Repository that extends CrudRepository. Inside there I have a custom query:
public interface CustomerRepository extends CrudRepository {
@Query("select * from person where firstname = :firstname")
…

eyeprime
- 75
- 1
- 8
1
vote
1 answer
Pageable not giving expected results with @ManyToMany relationship
We are dealing with @ManyToMany relation with Users and Roles and want to have pagination to get all the Users with associated Roles by using Pageable interface. It is only considering the records count for pagination on the User Table and Roles…

Manoj Kumar
- 89
- 7
1
vote
3 answers
How to accept @OrderBy of JPA sort value as a dynamic parameter?
I want to sort a nested collection property dynamically based on the query parameter sort.
Suppose i have an entity A as
class A{
@OneToMany(mappedBy="a")
private Set bset;
}
class B{
private LocalDate datefield;
@ManyToOne
private C…

Jill
- 163
- 1
- 5
- 20
1
vote
0 answers
How to combine mongodb view with pageable and querydsl?
My case: pageable and filtering (querydsl) of nested object (ObjectB - not unique).
Simplify data structure:
@Document(collection= "ObjectA")
class ObjectA {
String id;
List list;
}
class ObjectB {
String name;
}
I can't use…

Xalion
- 623
- 9
- 27
1
vote
0 answers
How to fix "BeanInstantiationException: Failed to instantiate [org.springframework.data.domain.Pageable]: Specified class is an interface" error?
I have got "org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.domain.Pageable]: Specified class is an interface" every time I call rest controller method with Pageable parameter. Others controller…

pierug
- 11
- 2
1
vote
1 answer
Call "Optional#isPresent()" before accessing the value issue with Pageable
I am using Spring Data Mongo Pageable and Sonar giving me below error:
Optional optional = pageable.getSort().stream().findFirst();
if(optional.isPresent()) {
direction = pageable.getSort().stream().findFirst().get().getDirection();
…

PAA
- 1
- 46
- 174
- 282
1
vote
0 answers
The value for annotation attribute PageableDefault.size must be a constant expression
I already went through many links but did not find solution. Here is my code:
@Value("${paging.default.pageSize}")
public int pageSize;
Controller method:
@GetMapping()
public ResponseEntity> getAllEmployee(@PageableDefault(size =…

PAA
- 1
- 46
- 174
- 282