[p-277 of EJB3 In Action Book] talks about only unidirectional one-to-one. How about bidirectional one-to-one using @PrimaryKeyJoinColumn? Do i have to specify
mapped-by attribute as i did it for bidirectional one-to-one using @JoinColumn.
If you have a bi-directional OneToOne, then you should always use mappedBy in the direction opposite to the foreign key constraint.
There are basically two pieces of information in the OneToOne, which foreign key field should be written to from the relationship, and whether the source or target should be inserted to the database first.
Using mappedBy, means don't write any foreign keys from the reference, and insert this object first.
Using a @PrimaryKeyJoinColumn means the object has foreign keys, but because it also maps them using basic Id attributes, don't write to any of the foreign keys from the reference, and insert the referenced object first.
Using a @JoinColumn means the object has a foreign key, write to it from the reference (unless it is insertable/updateable false), and insert the referenced object first.