Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements count() for named queries #10455

Merged

Conversation

loicmathieu
Copy link
Contributor

Fixes #10319

@loicmathieu
Copy link
Contributor Author

@FroMage to implement a count() for a named query I had to retrieve the query string. The easiest way I find is by creating the named query and casting it to org.hibernate.query.Query.

As the code is alreadt couple to Hibernate I don't think it's an issue but maybe you know a better way to do this.

I could have processed the @NamedQuery annotation at build time to create a cache of queries, but I found this overkill, as count is cached inside PanacheQuery, this code don't have to be performance efficient.

Copy link
Member

@FroMage FroMage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@FroMage
Copy link
Member

FroMage commented Jul 3, 2020

Yeah, this works fine enough, thanks a lot!

@gastaldi gastaldi added this to the 1.7.0 - master milestone Jul 3, 2020
@gastaldi gastaldi added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Jul 3, 2020
@gastaldi gastaldi merged commit b4f6b6c into quarkusio:master Jul 7, 2020
@loicmathieu loicmathieu deleted the hibernate-panache-count-named-query branch July 8, 2020 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-orm Hibernate ORM area/panache triage/waiting-for-ci Ready to merge when CI successfully finishes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to perform a count operation on a named query
3 participants