我有以下型号
public class Question {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@ManyToMany(cascade = {
CascadeType.PERSIST,
CascadeType.MERGE
})
@JoinTable(name = "question_tag",
joinColumns = @JoinColumn(name = "question_id"),
inverseJoinColumns = @JoinColumn(name = "tag_id"))
private List<Tag> tags;
}
public class Tag {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private String tagName;
@ManyToMany(mappedBy = "tags")
private List<Question> question;
}
我想获取tagName的直方图,以使用JPQL对每个标签的问题进行计数。