我得到了我的模特
public class Comic implements Serializable {
@Id
@Basic(optional = false)
@Column(name = "id")
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
@ManyToMany
private Set<User> owners;
(lots of blah blah blah)
}
我希望查询我所拥有的任何漫画的所有者的总数,其他只是为了加入表格中的多行。但我不知道如何参考这张桌子? JPA2.0中的这个查询应该如何?
答案 0 :(得分:3)
这样的事情:
select count(o) from Comic c join c.owners o