spring-projects / spring-projects/spring-data-relational

Add page support for Custom query @Query with different SQL future like join, etc...

Open
#958 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Java
Stars
827
Forks
394
PR merge metrics
No merged PRs in 30d

Description

Hi,

I am working on a project with Spring DATA JDBC, I have different custom queries in my Repository such as:

@Query("SELECT test1, test2 FROM table where test1 = :test1 AND (:test2 IS NULL OR test2 =:test2)) "
List findTest(String test1, String test2, Peagabe peagable)

@Query ("SELECT a.test1,a.test2 FROM tabe a inner join table2 b on a.test1 = b.test1 WHERE test1 = (SELECT test1 from table3 c where c.test5= :test))
List findOtherTest(String test, Pageable peagable)

or more complicted queries.
P.S I wrote these queries without testing, I want just give the idea

There are two issues :

  1. if I return a List from the method (List findTest(String test1, String test2, Peagabe peagable)) linked to the Query, even if I am passing an instance of Pageable to that method, it will return me all the records that it found. regardless of which size number I passed. (PageRequest pageable = PageRequest.of(0,1))

  2. If I return a Page from the method (Page findTest(String test1, String test2, Peagabe peagable)) linked to the Query, It gives me org.springframework.dao.IncorrectResultSizeDataAccessEception : Incorrect result size: expected 1, actual 10

Would you please exlain me about these issues and if Spring is considering to add these futures in Spring Data JDBC?
Thanks

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by reproducing the two custom @Query repository cases using Pageable, then trace Spring Data JDBC's handling of List and Page results; done means an agreed pagination behavior for complex queries with regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, sql
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.