| In the following example, I have a one-to-one relationship. I do not use mappedBy because the Item class can be in 2 different columns of the container class. When I persist the container class, the Item's container_id is always NULL. Even if I persist the Container class, start a new transaction load the container, and then set and merge the Item with the managed container, the item's container_id is always NULL. The only way I can get the container_id set is to create a new entity manager, load the Container, set the item's container, and then merge the item. This only works in a new entity manager, not the one used to persist the Container, and that seems to be inconsistent. @Entity public class MyContainer { @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER) @JoinColumn(name = "item_good_id") Item goodItem; @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER) @JoinColumn(name = "item_bad_id") Item badItem; } @Entity public class Item { @OneToOne @JoinColumn(name = "container_id") MyContainer myContainer; } |