POJO's are :
@Embeddable
public class CollegesId implements java.io.Serializable {
private String collegeName;
private Integer collegeRssId;
public CollegesId() {
}
public CollegesId(String collegeName, Integer collegeRssId) {
this.collegeName = collegeName;
this.collegeRssId = collegeRssId;
}
@Column(name = "college_name", length = 80)
public String getCollegeName() {
return this.collegeName;
}
public void setCollegeName(String collegeName) {
this.collegeName = collegeName;
}
@Column(name = "college_rss_id")
public Integer getCollegeRssId() {
return this.collegeRssId;
}
public void setCollegeRssId(Integer collegeRssId) {
this.collegeRssId = collegeRssId;
}
public boolean equals(Object other) {
if ((this == other))
return true;
if ((other == null))
return false;
if (!(other instanceof CollegesId))
return false;
CollegesId castOther = (CollegesId) other;
return ((this.getCollegeName() == castOther.getCollegeName()) || (this
.getCollegeName() != null
&& castOther.getCollegeName() != null && this.getCollegeName()
.equals(castOther.getCollegeName())))
&& ((this.getCollegeRssId() == castOther.getCollegeRssId()) || (this
.getCollegeRssId() != null
&& castOther.getCollegeRssId() != null && this
.getCollegeRssId().equals(castOther.getCollegeRssId())));
}
public int hashCode() {
int result = 17;
result = 37
* result
+ (getCollegeName() == null ? 0 : this.getCollegeName()
.hashCode());
result = 37
* result
+ (getCollegeRssId() == null ? 0 : this.getCollegeRssId()
.hashCode());
return result;
}
}
@Entity
@Table(name = "colleges", catalog = "lookups")
public class Colleges implements java.io.Serializable {
private CollegesId id;
private Collegerss collegerss;
public Colleges() {
}
public Colleges(CollegesId id) {
this.id = id;
}
public Colleges(CollegesId id, Collegerss collegerss) {
this.id = id;
this.collegerss = collegerss;
}
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "collegeName", column = @Column(name = "college_name", length = 80)),
@AttributeOverride(name = "collegeRssId", column = @Column(name = "college_rss_id"))})
public CollegesId getId() {
return this.id;
}
public void setId(CollegesId id) {
this.id = id;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "college_rss_id", insertable = false, updatable = false)
public Collegerss getCollegerss() {
return this.collegerss;
}
public void setCollegerss(Collegerss collegerss) {
this.collegerss = collegerss;
}
}
@Entity
@Table(name = "collegerss", catalog = "lookups")
public class Collegerss implements java.io.Serializable {
private Integer collegeRssId;
private String sportsRss;
private Set<Colleges> collegeses = new HashSet<Colleges>(0);
public Collegerss() {
}
public Collegerss(String sportsRss, Set<Colleges> collegeses) {
this.sportsRss = sportsRss;
this.collegeses = collegeses;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "college_rss_id", unique = true, nullable = false)
public Integer getCollegeRssId() {
return this.collegeRssId;
}
public void setCollegeRssId(Integer collegeRssId) {
this.collegeRssId = collegeRssId;
}
@Column(name = "sports_rss", length = 128)
public String getSportsRss() {
return this.sportsRss;
}
public void setSportsRss(String sportsRss) {
this.sportsRss = sportsRss;
}
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "collegerss")
public Set<Colleges> getCollegeses() {
return this.collegeses;
}
public void setCollegeses(Set<Colleges> collegeses) {
this.collegeses = collegeses;
}
}
|