Skip to content

NativeQuery with Pagination #2260

@Johnczek

Description

@Johnczek

Hello, I am facing issue similiar with #1282.

I am trying to run this native query with spring-data on version 2.5.0

@Query(value = "SELECT dense_rank() OVER (ORDER BY rank DESC)," + "t.id, " + "FROM table t WHERE t.x > 0 ", nativeQuery = true) Page<Object[]> getT(Pageable pageable);

But I am getting SQLGrammarException because the spring-data engine will translate this query into

SELECT dense_rank() OVER (ORDER BY rank DESC),t.id FROM table t WHERE t.x > 0 , t.y desc limit 20

Where the problem is pretty obvious. There is ORDER BY clause missing, probably because of presence of ORDER BY clause in OVER subquery. Is this a known bug? And is it possible to bypass this somehow? I need to use whole pageable object with native query with this dense_rank() calling.

Metadata

Metadata

Assignees

Labels

in: query-parserEverything related to parsing JPQL or SQLtype: bugA general bug

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions