[jboss-user] [EJB 3.0] - problem withonetoone mapping

mravikrish do-not-reply at jboss.com
Fri Nov 21 00:16:09 EST 2008


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

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4191118#4191118

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4191118



More information about the jboss-user mailing list