-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: ManytoOne composite primary key issue
PostPosted: Wed Jan 17, 2007 7:50 am 
Newbie

Joined: Wed Jan 17, 2007 1:26 am
Posts: 1
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;
}
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.