aspose file tools*
The moose likes Object Relational Mapping and the fly likes OneToOne Bidirectional Using @PrimaryKerJoinColumn Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "OneToOne Bidirectional Using @PrimaryKerJoinColumn" Watch "OneToOne Bidirectional Using @PrimaryKerJoinColumn" New topic

OneToOne Bidirectional Using @PrimaryKerJoinColumn

Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 390
[P-276 od EJB3 In Action book] states:
"In a bidirectional relationship, the owning side of the relationship is the entity that stores the relationship in its underlying table."
Now, consider the same example of User and BillingInfo.


Now as BILLING_INFO table contains the FK, BillingInfo entity is the owning side of the relationship.
Now according to the owning side definition, the classes should be:
class BillingInfo{
@Column (name="BILLING_USER_ID")
protected Long userId;

@PrimaryKeyJoinColumn(name="USER_ID" referencedColumnName="USER_ID")
User user;

class User{
protected Long userId;

BillingInfo billingInfo;

but in the book, the classes are defined as :

public class User {
protected Long userId;
protected BillingInfo billingInfo;

public class BillingInfo {
protected Long userId;
I agree. Here's the link:
subject: OneToOne Bidirectional Using @PrimaryKerJoinColumn
Similar Threads
Annotations doubt
One-To-One Bidirectional - Owning Side & mappedBy property?
Question about the type of JoinColumn.
Naive question on "MappedBy" attribute of @OneToMany
Issues with @PrimaryKeyJoinColumn