When I call custom method in PagingAndSortingRepository with Pageable object set to page > 0 the generated query has misplaced first and skip parameters (They are inserted by Spring + Hibernate) and I do not have any control over them.
Example:
Pageable paging = PageRequest.of(1, 10);
Page items = repository.findByMaterialSizesQuery(25, paging);
Log output:
Hibernate:
select
skip ? first ? t_m_gatunki.id,….
Which results in Error:
There was an unexpected error (type=Internal Server Error, status=500).
could not prepare statement [Dynamic SQL Error; SQL error code = -104; Token unknown – line 1, column 21; ? [SQLState:42000, ISC error code:335544634]]
Certainly properly generated query should look like this
Hibernate:
select
first ? skip ? t_m_gatunki.id,….
I have to say that when I use standard methods e.g repository.findAll(paging) everything is OK and first and skip are at proper positions.
Hoping for any solutions.
Tried to leverage runtimeOnly ‘org.firebirdsql.jdbc:jaybird:5.0.4.java11’. Tried to implemet QueryRewriter with Repository but the query in rewrite method is still not prepared statement so no effect.
Zadra is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.