I'm trying to map something roughly the same as the
org.hibernate.test.onetoone.formula example but with annotations (and unidirectional).
In practice, I'm trying to create a join between
post
id (PK)
type
posted_by (FK on person_name below)
and:
alt_names
id (PK)
person_name
type
alt_name
where the type in the person decides which alt_names row is picked.
I'm almost there with the following (in italics) but it's not happy (not a unique row returned).
@Entity
@Table...
post
@Id
id (PK)
type
@OneToOne(mappedBy="type")
@JoinColumn(name="posted_by", referencedColumnName="person_name", unique=true)
posted_by
Thanks in advance,
Digby