0

I have two Pojo's Club and Team both has common table column called clubId, then i need to get records from the both the table when Club.clubId equals Team.clubId.

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

I have both the POJO's with Relationship defined over there as like below

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

;
snieguu
  • 2,073
  • 2
  • 20
  • 39
Thirukumaran
  • 357
  • 3
  • 5
  • 17
  • As you are having relationship between these both two table so you dont need to have any comparison just fire join query . – Gokul Aug 18 '16 at 05:59
  • ok but Still i like to know how would do that , if i need to do in some other scenario where i don't have relationship defined – Thirukumaran Aug 18 '16 at 06:14
  • Got it, we can do that with eqProperty of Restrictions in CreateCriteria thanks – Thirukumaran Aug 18 '16 at 06:31

0 Answers0