-->
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.  [ 2 posts ] 
Author Message
 Post subject: OneToOne relation gives problem
PostPosted: Sat Jan 19, 2008 5:21 am 
Newbie

Joined: Fri Dec 28, 2007 7:38 am
Posts: 16
This is my TBL_PRODUCTS table structure is
Code:
PRODUCT_ID       pk
PRODUCT_NAME
CATEGORY_NAME
SUBCATEGORY_NAME
BRAND_NAME

This is my TBL_CELLPHONE table structure is
Code:
PRODUCT_ID       pk
BLUETOOTH
CAMERA

This is my TBL_TELEVISION table structure is
Code:
PRODUCT_ID       pk
NO_OF_CHANNELS
WOOFERS

and my entity beans are
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;

@Column(name="CATEGORY_NAME")      
   private String categoryName;   

   @Column(name="SUBCATEGORY_NAME")   
   private String subcategoryName;

   @Column(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 bluetooth;      

   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="NO_OF_CHANNELS")
   private String noOfChannels;

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


TblProducts is my main table. I try to add OneToOne relation with other tables (TblTelevision and TblCellphone). I cant add more than one relation. If I add it gives incomplete deployment problem. If I remove any one of the OneToOne relation from TblProducts its works fine.
Is there any mistake in my code
Please help me

By
Thiagu.m


Top
 Profile  
 
 Post subject: Re: OneToOne relation gives problem
PostPosted: Sat Jan 19, 2008 11:45 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
First off, instead of @JoinColumn use @PrimaryKeyJoinColumn. What is the exception?


Farzad-


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

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.