Named query invocations are missing in Panache.
Adding named queries can make #3482 less of a priority, since hints can be directly defined in the annotated named query.
@galderz which named queries do you want Panache to support?
Named queries via the @NamedQuery annotation so someone can annotate it's entity with a query and use it in one of the find method of Panache like this:
@Entity
@NamedQuery(name="Country.findAll", query="SELECT c FROM Country c")
public class Country extends PanacheEntity {
// ...
}
Country.find("Country.findAll");
// or
Country.findByQuery("Country.findAll");
Or adding to the existing find/list/stream/count/Delete methods an overload to allow passing a Query object ?
TypedQuery query = Country.getEntityManager()
.createNamedQuery("SELECT c FROM Country c", Country.class);
List<Country> countries = Country.list(query);
Personaly I favor the second one, but the first one can also allow to specify hints and lockmode (there is issue #2744 to support lockmode in Panache)
I don't really mind which TBH, I'm happy with whatever is more idiomatic for Panache.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you!
We are doing this automatically to ensure out-of-date issues does not stay around indefinitely.
If you believe this issue is still relevant please put a comment on it on why and if it truly needs to stay request or add 'pinned' label.
Please support NamedQuery. I have a bunch of namedQueries in old jee project and want to reuse it:
For example:
@NamedQuery(
name = User.byName,
query = "select distinct u from User u where u.name =:name",
hints = @QueryHint(name = QueryHints.COMMENT, value = "User.name: Get User by name."))
and use it in a PanacheEntity:
// this NamedQuery also has "jpa or hibernate hints" which must be considered in panache
User.find("User.byName");
// or User.query("User.byName");
And please also support @NamedEntityGraph in Panache:
// this NamedEntityGraph also has "jpa or hibernate hints" which must be considered in panache
User.find("User.entityGraph");
// or User.query("User.entityGraph");
We would also like to have this. Any idea on the ETA?
@nimo23 for named entity graph they can be used via a query Hint javax.persistence.fetchgraph.
Hints are already supported via find(query).withHint()
Most helpful comment
@nimo23 for named entity graph they can be used via a query Hint
javax.persistence.fetchgraph.Hints are already supported via
find(query).withHint()