[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - NPE:OneToOneSecondPass.java:135 - Consecutive One to one rel
virtual82
do-not-reply at jboss.com
Tue Oct 16 06:04:44 EDT 2007
Hi Guys, this is my environment:
java 1.6
jboss-version: 4.0.5.GA
Seam-Version: 1.2.1.GA
Hibernate-Version: 3.2.3.ga
I' m using annotation and javax.persistence.EntityManager.
the problem is in the mapping of the following schema (the relation are all one-to-one):
First <-(Fk to First)-Second <-(Fk to Second)-Third
.First has a pk generated by a sequence.
.Second and Third tables have pk=fk
this is my mapping:
=======================
public class EBFirst implements java.io.Serializable {
private EBSecond eBSecond;
@GenericGenerator(name="generator", strategy="myGenerator.TriggerGenerator")
@Id
@GeneratedValue(generator="generator")
@Column(name="PK_ID", unique=true, nullable=false, columnDefinition="NUMBER", precision=28, scale=0)
public BigDecimal getPkId() {
return this.pkId;
}
@OneToOne(mappedBy="EBFirst", cascade=CascadeType.ALL)
public EBSecond getEBSecond() {
return eBSecond;
}
.
.
.
}
------------
public class EBSecond implements java.io.Serializable {
private EBFirst EBFirst;
private EBThird eBThird;
@GenericGenerator(name="generator", strategy="foreign", parameters = {@Parameter(name = "property", value = "EBFirst")})
@GeneratedValue(generator="generator")
@Id
@Column(name="PK_ID", unique=true, nullable=false, columnDefinition="NUMBER", precision=28, scale=0)
public BigDecimal getPkId() {
return this.pkId;
}
@OneToOne
@PrimaryKeyJoinColumn
public EBFirst getEBFirst() {
return this.EBFirst;
}
@OneToOne (mappedBy="EBSecond", cascade=CascadeType.ALL)
public EBThird getEBThird() {
return eBThird;
}
.
.
.
}
-------------
public class EBThird implements java.io.Serializable {
@GenericGenerator(name="generator", strategy="foreign", parameters = {@Parameter(name = "property", value = "EBSecond")})
@GeneratedValue(generator="generator")
@Id
@Column(name="PK_ID", unique=true, nullable=false, columnDefinition="NUMBER", precision=28, scale=0)
public BigDecimal getPkId() {
return this.pkId;
}
@OneToOne
@PrimaryKeyJoinColumn
public EBSecond getEBSecond() {
return this.EBSecond;
}
.
.
.
}
=======================
this is the exception at startup:
[org.jboss.system.ServiceController] Problem starting service persistence.units:ear=cerssvd.ear,jar=cerssvd.ejb3.jar,unitName=entityManager
java.lang.NullPointerException
at org.hibernate.cfg.OneToOneSecondPass.doSecondPass(OneToOneSecondPass.java:135)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1054)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1039)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1211)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:847)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:385)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:264)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
.
.
.
the problem is in the class EBSecond at the following:
@OneToOne (mappedBy="EBSecond", cascade=CascadeType.ALL)
he doesn't like the attribute mappedBy="EBSecond". But it's mandatory (in this context)
Can someone help me?
Thanks, Gianpaolo
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4095544#4095544
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4095544
More information about the jboss-user
mailing list