Skip to content

Pagination not working when using native queries (Named query exists but its result type is not compatible) #2586

Closed as not planned
@bodiam

Description

@bodiam

Hi all,

I'm having an issue with pagination + projections + orm.xml + native queries.

I've described the issue in full detail here: https://stackoverflow.com/questions/72859385/hibernate-pagination-not-working-when-using-native-queries-named-query-exists-b, and I've created a fully reproducible sample here: https://github.com/bodiam/hibernate-bug, but in a nutshell, the issue is that when I create a native count query, the result type of the count query is not compatible.

Most likely the issue is here:

countQuery = em.createNamedQuery(countQueryName, Long.class);
or here .

I have a workaround for now, which is to specify the mapping of the result like so:

    <sql-result-set-mapping name="cntColumnResult">
        <column-result name="cnt"/>
    </sql-result-set-mapping>

But I was hoping there might be a slightly more user friendly way of dealing with this, since it's been giving me quite the troubles to fix this (thanks Eugene!)

Metadata

Metadata

Assignees

Labels

in: repositoryRepositories abstractionstatus: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions