我有两个 Pojo's Club 和 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
;