JPA 2.0 OneToOne Mapping Reference a Attribute
Is it possible to reference one attribute in a referenced entity in relation to OneToOne
Example:
@Entity
public class Country {
@Id
private Long countryId;
@Column(name="code")
private String countryCode;
...
}
@Entity
public class City {
@Id
private Long cityId;
@OneToOne
@JoinColumn(name="countryId",referencedColumnName="cityId")
@Column(name="code")
private String countryCode;
}
With this setting, I am getting @Column (s) error not allowed in @OneToOne property. Is it possible to do it another way in JPA 2.0
thanks sanjay
+3
source to share