Hello,
I am having a problem with onetoone mapping .in my project i have mapped project--->buyerrating onetoone and project---->vendorrating onetoone. and this is my mappings code. please suggest me where i did mistake.
this is project entity
@Entity
@Table(name = "PROJECT")
public class Project implements Serializable{
private int projectId;
private BuyerRating buyerRating;
private VendorRating vendorRating;
@Id
@GeneratedValue( strategy=GenerationType.SEQUENCE, generator="projectid_sequence" )
@SequenceGenerator( name="projectid_sequence", sequenceName="PROJECTID_SEQ" )
@Column(name = "PROJECTID")
public int getProjectId() {
return projectId;
}
public void setProjectId(int projectId) {
this.projectId = projectId;
}
@OneToOne(cascade={CascadeType.ALL},mappedBy="project")
public BuyerRating getBuyerRating() {
return buyerRating;
}
public void setBuyerRating(BuyerRating buyerRating) {
this.buyerRating = buyerRating;
}
@OneToOne(cascade={CascadeType.ALL},mappedBy="project")
public VendorRating getVendorRating() {
return vendorRating;
}
public void setVendorRating(VendorRating vendorRating) {
this.vendorRating = vendorRating;
}
this is vendorrating entity
@Entity
@Table(name="VENDORRATING")
public class VendorRating implements Serializable{
private int projectId;
private Project project ;
@OneToOne()
@JoinColumn(name="PROJECTID",unique=true,insertable=false,updatable=false,nullable=false)
public Project getProject() {
return project;
}
public void setProject(Project project) {
this.project = project;
}
and exception is as follows
java.lang.NullPointerException
at org.hibernate.cfg.OneToOneSecondPass.doSecondPass(OneToOneSecondPass.java:135)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130)
at ....org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)....................
Thank you
K ramu
Could you also post the entity "BuyerRating"?
Remember to wrap all code snippets in "code" blocks and preview the result before posting.
Best regards
Wolfgang