105 questions
1
vote
1
answer
32
views
Pageable pageSize and PageNumber max limit
in Controller if PageNumber and PageSize is given larger than int it crashes how can i write constraints not to have PageNumber and Pagesize larger than some reasonable number?
i tried finding ...
0
votes
0
answers
41
views
Spring Boot JPA Projection don't work with Specification and Pagable as expected
I have simple entity.
When I invoke findPageableCommunityAccess from below examples I'm receiving result that look like CommunityAccess (full object) instead CommunityAccessProjection.
Do Projections ...
1
vote
1
answer
286
views
Combine two Pages with different Entities
I need to combine data from two different DTOs (or entities) into a single pageable result.
**The Problem
**
I have two lists of DTOs, both of which are fetched separately from the database and ...
1
vote
0
answers
37
views
Spring Boot pageable issue, receied empty pageable structure
On my app, pageable methods are run successfully and got Status 200 ok on Postman checking, however content is empty, and we can not see the list of adverts on Postman. We just have Status 200 ok and ...
0
votes
1
answer
174
views
Customize response from Pageable, Spring Boot(Kotlin)
I have an endpoint that uses pagination and Pageable and returns various information, I don't need all this information and I wanted to remove/add some. Is there a way to do this?
@GetMapping
...
0
votes
0
answers
95
views
Try to test a service by mocking a repository method which requires passing Pageable. The unit test always thows java.lang.NullPointerException
Cannot properly mock the method in repository which requires passing Pageable. I tried everything I could find. PLEASE HELP.
So I cannot mock findAllByTypeContainsAndSexLike method
TEST CLASS:
@...
1
vote
1
answer
828
views
The return type is incompatible with '@NonNull Page<M>' returned from PagingAndSortingRepository<M,String>.findAll(Pageable)
Code:
@NoRepositoryBean
public interface AbstractRepository <M extends AbstractModel> extends MongoRepository<M, String> {
Page<M> findAll(Pageable pageable);
Page<M> ...
-1
votes
1
answer
367
views
Spring Data Slice in Cassandra
Actually i'm using Slice to pagination in queries in Cassandra. My repository is declared like this:
@Repository
public interface MovementsRepository<T> extends CassandraRepository<Movements, ...
0
votes
0
answers
87
views
how to make Pageable query able to fetch all the rows
Unable to fetch and update all the rows having source_channel as SourceChannels.DRIVER_REFERRAL_CHANNEL.
batchSize = 2
Page<Lead> driverReferralLeads = repository....
0
votes
0
answers
1k
views
Page.getTotalElements() returns the number of total data in table not the number of result of query
hi Iam using spring boot, JPA
I used Pageable objects to do Pagination
and when I get each Page, I got totalElements by using getTotalElements()
I expected to get the number of searching result, but I ...
0
votes
0
answers
2k
views
Using @ParameterObject or @PageableAsQueryParam to set description about Pageable in swagger doc
right now, I am making swagger doc.
swagger img
I want to customize that description about page, size and sort.
@GetMapping("/test")
public page<TestDTO> getTest(@ParameterObject ...
0
votes
1
answer
244
views
400 if Pageable cannot be parsed
Recently I was informed about a bug.
The tester executed the following request:
curl -X 'GET' 'http://zones:26081/zones/vehicles-by-day?date=2023-05-20&page=0&size=10&sort=string'
And got ...
0
votes
1
answer
514
views
How to change Pageable defaulte maxSize behaviour?
everyone. I have a controller with Specification and Pageable parameters. If I need to return data form db in a usual way - everything works fine. I get my data by 20 size pages. Like this:
..........
0
votes
1
answer
115
views
Can Spring Data Pageables be used with raw JDBC queries?
Spring Boot here. I've seen Pageable used with repository methods like so:
@Repository
public interface SomeThingRepository extends JpaRepository<SomeThing, Long> {
List<SomeThing> ...
1
vote
0
answers
811
views
How to use Spring Data Pageable to query two repositories
How can I use Spring Data JPA to find results in two repositories using Pageable?
Consider that we have 2 repositories: the first repository has 5 rows matching a certain condition. The second ...
0
votes
1
answer
348
views
InvalidPathException while sorting with org.springframework.data.domain.Pageable
I am trying to sort my table's content on the backend side, so I am sending org.springframework.data.domain.Pageable object to controller. It arrives correctly, but at the repository I am getting org....
0
votes
1
answer
499
views
some problem with mock test for specification class
I'm new to programming, I want to make tests for my Specification class, but I can't figure out where I should start...how to approach this test?
public class MySpecification implements Specification&...
0
votes
2
answers
867
views
ERROR: syntax error at or near "." - JPA Pageable
repository:
@Repository
public interface PostRepository extends PagingAndSortingRepository<Post, Long> {
@Query(value = "SELECT p.postComments FROM Post p WHERE p.webId = ?1")
...
0
votes
1
answer
2k
views
Paged blobs from azure storage
I am curently trying to get a list of paged blobs from azure, but I don't really know how and I am kind of stuck. I have this method that is Pageable (it acces the blobs for a specific student, based ...
1
vote
1
answer
467
views
Can one get repeated results on an unsorted page?
if I request for a Page of results from my DB without any ordering provided
val page1 = repository.findAll(PageRequest.of(1,10))
val page2 = repository.findAll(PageRequest.of(2,10))
Could page1 and ...
1
vote
1
answer
3k
views
Passing Spring pageable in get request
If I send a request from Spring application:
public ResponseEntity<RestResponsePage<Result>> readDocs(
Pageable pageable
) {
HttpHeaders requestHeaders = new HttpHeaders();
...
0
votes
0
answers
518
views
Springboot Pageable with Specification JPA problem
i have a data problem for my code:
PeopleSpec peopleSpec = new PeopleSpec(req.getSearchFilters(), jsonReqRes.getOrder());
int currentPage = req.getCurrentPage() - 1;
int elementForPage = ...
-1
votes
1
answer
182
views
Implementing Page with Filtering
i have this repository, service and controller, and i have no ideea how to solve the error that i m getting in service, any suggestions please? (Type mismatch: cannot convert from List<UtenteDto>...
1
vote
0
answers
294
views
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 ...
4
votes
1
answer
2k
views
Specify complex sorting criteria when requesting Spring Data JPA repository
I'm requesting paged and sorted data from my database, specified via Pageable with following repository API:
org.springframework.data.jpa.repository.JpaSpecificationExecutor.findAll(Specification<...
0
votes
1
answer
1k
views
How to map from Page<ObjectOne> to Page<ObjectTwo> in Spring Data 2?
I'm looking at some old code and I'm trying to re-write it however I encountered a problem.
This is the old code that works perfectly fine:
public Page<SearchResult> search(String text, int ...
0
votes
1
answer
871
views
Spring application using Pageable always returns the same result from page 2
I'm using spring to develop an application using sqlite as a database, but I'm having a problem implementing pagination in the repository's findAll(Pageable pageable) method.
For this implementation I'...
0
votes
1
answer
364
views
not able to parse pageable response array to dto in java
I am working on a spring boot app where I am getting pageable response and then I want to take that pageable response array to parse it to a list of some DTO.
Here's my function:
public Object ...
0
votes
0
answers
1k
views
Pageable compenent is passed as null even we pass page,size,sort object
I have a rest controller that takes pageable as a parameter
@GetMapping(value = "/user", produces = APPLICATION_JSON_VALUE,
consumes = APPLICATION_JSON_VALUE)
public BaseResponse ...
0
votes
1
answer
84
views
How to properly hide absolute elements on full page scrolling?
while the code I wrote works, because the page have couple of these absolute elements. it takes a couple milliseconds to hide them, so users who have low-end hardware will sometimes see the absolute ...
0
votes
0
answers
269
views
Pageable Sorting not working with named native query in orm.xml using spring boot
I have defined the named native query in orm.xml which maps to the method declared in repository interface
Student Repository
@Query(nativeQuery = true)
public List<DeptStuInfo> ...
1
vote
1
answer
3k
views
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 ...
1
vote
2
answers
571
views
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 ...
4
votes
1
answer
1k
views
Memory leak with Criteria API Pageable
I implemented pageable functionality into Criteria API query and I noticed increased memory usage during query execution. I also used spring-data-jpa method query to return same result, but there ...
0
votes
1
answer
62
views
Im making a app and a part of it is adding blogs in it made by a user, and I cant differ them in more than one page
@Entity
@Table(name="blogs")
public class Blog {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false, length = 300)
private ...
3
votes
1
answer
4k
views
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 ...
0
votes
2
answers
5k
views
How to set TotalPages of a PageImpl class in spring boot
I'm converting a Page to a new one by using PageImpl class, but the totalpages attribute has the default value 0. I would like to set totalPages to a specific number. Is it possible to change it?
code
...
0
votes
0
answers
2k
views
Feign client error - Page size must not be less than one
I have the following Rest controller method:
@GetMapping
public Page<CompanyDto> findAllCompanies(@RequestParam(value = "name", required = false) String name, Pageable pageable, ...
0
votes
2
answers
3k
views
Spring Boot: Slice/Pageable not returning proper chunk based on page
In my PSQL DB, I have two objects stored and I would like to retrieve each item on their separate page/slice. I am trying to achieve this by passing in the following Page objects:
PageRequest.of(0,1) ...
0
votes
1
answer
123
views
How to fix convertion error using mongorepository with pageable
I'm getting the following error when pageable's page is 3 or higher (with values 1 or 2 it works). The error is coming from a call to mongorepository.
Failed to convert from type [java.lang.String] to ...
3
votes
3
answers
1k
views
Spring pageable sort on other entity's nullable attribute
I came across the following problem... I have three entities:
@Entity
class Contract {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@ManyToOne
...
0
votes
0
answers
1k
views
Convert List to Slice in Spring
So my question is simple, I am getting a Slice<Object> from database using pageable.
Then I need to filter it based on some parameters(fe. status), so as usual I'm doing something like this:
...
1
vote
1
answer
546
views
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, ...
0
votes
1
answer
319
views
Save Kendo Pagable User Input To Persist Grid State
I'm having a problem with Kendo .Pagable. We have a webapplication that displays entries in a grid. The user can choose between 25, 50, 100, 200 entries per site. But whenever the user enters the ...
0
votes
0
answers
321
views
Spring data jpa, pageable adds own specs to custom query
i have a problem. I'm trying to do custom query with filtering by date usin time stamp, but im using Pageable and it adds to query after comma id desc limit and it causing error like below. I dont ...
0
votes
1
answer
2k
views
Pagable Sort.Order ignore case
(I'm using Micronaut)
I have a list of students and I want to sort it by name. I am using Pageable and sort as query parameters
http://localhost:8080/admin/students?page=0&size=10&sort=name,...
7
votes
1
answer
3k
views
Mockito - Kotlin test throws Null Pointer Exception when trying to capture Pageable argument
I have written a really simple test for a method in my controller using Mockito
@Test
fun `get items based on category ID`() {
val pageable: Pageable = PageRequest.of(5, 50)
controller.get(10, ...
0
votes
2
answers
880
views
Missing Attribute 'type' in Spring WebClient Response for Microservice Communication
I want to use WebClient to retrieve a page from another microservice. When I directly request the microservice using Postman, the response includes the type attribute among other fields in the content ...
-1
votes
1
answer
2k
views
Spring boot - subtraction inside sortBy (Pageable)
Is it possible to subtract two fields(numbers) inside sortBy in pagerequest like this??
PageRequest.of(page, size, Sort.Direction.ASC, "price-discount")
.
This is error i get..
Sort ...
3
votes
2
answers
7k
views
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 ...