如何在HQL

时间:2016-08-18 05:46:34

标签: hibernate hql hibernate-criteria criteria-api createquery

我有两个Pojo俱乐部和Team都有一个名为clubId的公共表列,当Club.clubId等于Team.clubId时,我需要从两个表中获取记录。

Could anyone help me to do check the equals based on the id's of two Pojos 

我同时在那里定义了关系的POJO,如下所示

Club POJO:    


public class Club implements Serializable,Comparable{
         @Id
         @GeneratedValue
         @Column(name = "clubId")
        private Integer clubId;

         @Column(name="name")
        private String name;

         @OneToMany(fetch = FetchType.EAGER,mappedBy = "club")
            private Set<Team> team=new HashSet<Team>(0);


    For Team:

    @Entity
    @Table(name="team")
    public class Team implements Serializable{

        @Id
        @GeneratedValue
        @Column(name="teamid")
        private Integer teamId;

        @Column(name="teamname")
        private String teamName;

        @ManyToOne(fetch = FetchType.LAZY)
        @JoinColumn(name = "clubid", nullable = false, insertable = false, updatable = false)
        private Club club

;

0 个答案:

没有答案