• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Devaka Cooray
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
Bartenders:

OneToOne relation gives problem

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 304
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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;
}
 
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Get meta with me! What pursues us is our own obsessions! But not this tiny ad:
Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders
https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing
reply
    Bookmark Topic Watch Topic
  • New Topic