JPQL ManyToMany计数直方图

时间:2018-08-27 06:44:36

标签: java spring-boot jpa many-to-many

我有以下型号

问题

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对每个标签的问题进行计数。

0 个答案:

没有答案