@Entity(name = "USERS")
@NamedQueries({
@NamedQuery(name = "custom.allActiveUsers", query = "FROM USERS u WHERE u.status = 1")
})
public class User extends PanacheEntity implements Serializable {
@Column(name = "version")
public Long version;
public static List<User> getActiveUsers() {
return find("#custom.allActiveUsers");
}
}
2条答案
按热度按时间olhwl3o21#
在你的User实体中写一些类似的东西(它应该扩展PanacheEntity):
字符串
另请参阅文档:https://quarkus.io/guides/hibernate-orm-panache#adding-entity-methods
w3nuxt5m2#
您需要将自定义查询声明为NamedQuery。请参阅:https://quarkus.io/guides/hibernate-orm-panache#named-queries
在您的场景中,它可能看起来像这样:
字符串