OneToOne relation gives problem
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
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
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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;
}
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;
}
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Which app server are you using?
What error are you getting? (show us the output)
What error are you getting? (show us the output)
Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
Bill Shirley
Ranch Hand
Posts: 457
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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 ]
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 ]
Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
| 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 |









