Hello,
I wanted to create a bi-directional @OneToOne. The Verifier mandates that I use a @JoinColumn and not a @Column.
Is this true?
I am using Glassfish RI, the accompanying Java DB (Derby) and the oracle toplink essentials that comes with the j2ee sdk.
There was no problem with using a @Column when it was an Uni Directional relationship. When I declared the fields each other, there were problems.
@Entity
@Table (name = "ORGANIZATION")
public class Organization implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "ORGANIZATIONID")
private int organizationId;
//Bi directional OneToOne
@OneToOne(optional=true)
@Column(name = "ADDRESS")
private Address address;
@Entity
@Table (name = "ADDRESS")
public class Address implements Serializable {
private int addressId;
@Column (name="ORGANIZATION")
@OneToOne(mappedBy="address", optional=true)
private Organization getOrganization() {
return this.organization;
}
private void setOrganization(Organization organization) {
this.setOrganization(organization);
}
Your help would be very useful.
Thanks in advance,
Rajesh