Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OneToOne relation gives problem

 
deepan thiagu
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

By
Thiagu.m
 
Mike Keith
author
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

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

String bluetooth;
String camera;

@OneToOne
@PrimaryKeyJoinColumn
TblProducts tblProducts;
}
 
Bill Shirley
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which app server are you using?
What error are you getting? (show us the output)
 
Bill Shirley
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic