-->
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: more than one OneToOne in a bean class gives problem
PostPosted: Fri Jan 11, 2008 6:42 am 
Newbie

Joined: Fri Dec 28, 2007 7:38 am
Posts: 16
This is my bean class structure

Code:
@Entity
@Table(name="TBL_PRODUCTS")
public class TblProducts implements Serializable
{
   @Id
   @Column(name="PRODUCT_ID")   
   private BigDecimal productId;

   @Column(name="PRODUCT_NAME")   
   private String productName;

   @JoinColumn(name="BRAND_NAME")   
   private String brandname;
   
   @OneToOne(fetch=FetchType.LAZY,mappedBy="tblProducts")   
   private TblCellphone tblCellphone;

   @OneToOne(fetch=FetchType.LAZY,mappedBy="tblProducts")
   private TblTelevision tblTelevision;

}

@Entity
@Table(name="TBL_CELLPHONE")
public class TblCellphone implements Serializable
{
   @Id
   @Column(name="PRODUCT_ID")   
   private BigDecimal productId;

private String camera;

. . .

@OneToOne(optional=false)
     @JoinColumn(name="PRODUCT_ID")   
private TblProducts tblProducts;
}

@Entity
@Table(name="TBL_TELEVISION")
public class TblTelevision implements Serializable
{
   @Id
   @Column(name="PRODUCT_ID")
   private BigDecimal productId;

   @Column(name="SCREEN_SIZE")
   private String screenSize;
   
   . . .

   @OneToOne(optional=false)
   @JoinColumn(name="PRODUCT_ID")   
   private TblProducts tblProducts;
}


Here Tblproduct is my main table , I need to make a relation with all other subcategory
But when I try this it gives me the following error

Code:
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)
   at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1233)
   at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
   at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:869)
   at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:407)
   at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
   at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:246)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)


is there any help how to overcome this problem

By
Thiagu.m


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.