jQuery in Action, 3rd edition
The moose likes EJB and other Java EE Technologies and the fly likes OneToOne relation gives problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "OneToOne relation gives problem " Watch "OneToOne relation gives problem " New topic

OneToOne relation gives problem

deepan thiagu

Joined: May 15, 2007
Posts: 18
This is my TBL_PRODUCTS table structure is

This is my TBL_CELLPHONE table structure is

This is my TBL_CELLPHONE table structure is

my entity beans are

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

Mike Keith
Ranch Hand

Joined: Jul 14, 2005
Posts: 304
First of all, it is never a good idea to use BigDecimal, or any floating point type, as a PK. Turns out that 1.0 may not be equal to 1.0 when rounding happens.

For your OneToOne relationships in your CellPhone and Television entity classes you should probably use the PrimaryKeyJoinColumn annotation to indicate that you are using the PK as the join column. For example, your cell phone class would look like:

public class TblCellphone implements Serializable {
Integer productId;

String bluetooth;
String camera;

TblProducts tblProducts;

Pro JPA 2: Mastering the Java Persistence API
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
Which app server are you using?
What error are you getting? (show us the output)

Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
Is a cellphone a type of product?
Is a television a type of product?

Are you sure you don't want an inheritance relationship?
EJB will map a table-per-class for you and maintain the 1-1 relationship of table entries.

In which case you want:

[ January 21, 2008: Message edited by: Bill Shirley ]
I agree. Here's the link: http://aspose.com/file-tools
subject: OneToOne relation gives problem
It's not a secret anymore!