2020年10月27日 | Leave a comment 问题: 解决: Article.java package t3dcool.web2.entity; import io.quarkus.hibernate.orm.panache.PanacheEntity; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; import io.quarkus.hibernate.orm.panache.PanacheQuery; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; import java.util.List; import java.util.Objects; @Entity @Table(name = "Article_Article") public class Article extends PanacheEntityBase { @Id @Column(name = "Id") public long id; @Column(name = "Title") public String title; @Column(name = "Star") public byte star; static List<Article> listByLabelId(long labelId, int limit) { PanacheQuery<PanacheEntityBase> q = Article.find(" id in (select articleId from ArticleLabel where labelId = ?1) ", labelId); var q2 = q.page(0, limit); return q2.list(); } } 1234567891011121314151617181920212223242526272829303132 package t3dcool.web2.entity; import io.quarkus.hibernate.orm.panache.PanacheEntity;import io.quarkus.hibernate.orm.panache.PanacheEntityBase;import io.quarkus.hibernate.orm.panache.PanacheQuery; import javax.persistence.Column;import javax.persistence.Entity;import javax.persistence.Id;import javax.persistence.Table;import java.util.List;import java.util.Objects; @Entity@Table(name = "Article_Article")public class Article extends PanacheEntityBase { @Id @Column(name = "Id") public long id; @Column(name = "Title") public String title; @Column(name = "Star") public byte star; static List<Article> listByLabelId(long labelId, int limit) { PanacheQuery<PanacheEntityBase> q = Article.find(" id in (select articleId from ArticleLabel where labelId = ?1) ", labelId); var q2 = q.page(0, limit); return q2.list(); } } 参考: https://quarkus.pro/guides/hibernate-orm-panache.html#定义你的实体entity