I am having issuing in loading a Entity with ManyToOne mapping having composite primary keys.
Scenario
I have three tables, provider, provider_education and schooluniv,
The provider and provider_education are linked by resource_id, this relation is
OneToMany.
provider_education and schoolunivtable are linked by src_id and school_id and this relation is
ManyToMany.
When I access the Entity(provider), i am able to see the query for both provider_education and schooluniv, but only
schooluniv object is getting populated whereas
provider_education is not getting populated.
Kindly throw some light on this.
I am using
EJB3.0/Hibernate3.2.0
Following is the code for the above mentioned entities,
Code:
Provider Entity
@Entity
@Table(name = "odb_provider", schema = "dbo", catalog = "ttgodb", uniqueConstraints = {})
public class OdbProvider implements java.io.Serializable {
private Set<OdbProviderEducation> odbProviderEducations = new HashSet<OdbProviderEducation>(0);
@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, mappedBy = "odbProvider")
public Set<OdbProviderEducation> getOdbProviderEducations() {
return this.odbProviderEducations;
}
}
Provider Education entity
@Entity
@Table(name = "odb_provider_education", schema = "dbo", catalog = "ttgodb")
public class OdbProviderEducation implements java.io.Serializable {
private OdbProviderEducationId id;
private OdbSchooluniv odbSchooluniv;
@EmbeddedId
@AttributeOverrides( {
@AttributeOverride(name = "resourceId", column = @Column(name = "resource_id", unique = false, nullable = false, insertable = true, updatable = true, length = 7)))
public OdbProviderEducationId getId() {
return this.id;
}
@ManyToOne(cascade = {CascadeType.ALL}, fetch = FetchType.LAZY)
@JoinColumns( {
@JoinColumn(name = "msoc_src_sys_id", unique = false, nullable = false, insertable = false, updatable = false),
@JoinColumn(name = "msoc_schl_id", unique = false, nullable = false, insertable = false, updatable = false) })
public OdbSchooluniv getOdbSchooluniv() {
return this.odbSchooluniv;
}
@Embeddable
public class OdbProviderEducationId implements java.io.Serializable {
private String resourceId;
}
SchoolUniv entity
@Entity
@Table(name = "odb_schooluniv", schema = "dbo", catalog = "ttgodb", uniqueConstraints = {})
public class OdbSchooluniv implements java.io.Serializable {
private OdbSchoolunivId id;
@EmbeddedId
@AttributeOverrides( {
@AttributeOverride(name = "msocSrcSysId", column = @Column(name = "msoc_src_sys_id", unique = false, nullable = false, insertable = true, updatable = true, length = 2)),
@AttributeOverride(name = "msocSchlId", column = @Column(name = "msoc_schl_id", unique = false, nullable = false, insertable = true, updatable = true, length = 10)) })
public OdbSchoolunivId getId() {
return this.id;
}
@Embeddable
public class OdbSchoolunivId implements java.io.Serializable {
private String msocSrcSysId;
private String msocSchlId;
}
}