In spring, we can declare a custom query like this
@Query(
value = "SELECT * FROM USERS u WHERE u.status = 1",
nativeQuery = true)
Collection<User> findAllActiveUsersNative();
but in Quarkus I cannot find a reference on how to do this in quarkus
Does anyone have any experience with how to do this?
2
Answers
Write something like this in your User entity (which should extend PanacheEntity) :
See also documentation:
https://quarkus.io/guides/hibernate-orm-panache#adding-entity-methods
You need to declare your custom queries as NamedQuery.
See: https://quarkus.io/guides/hibernate-orm-panache#named-queries
In your scenario, it could look like this: