Hibernate nastiness using the one-to-one mapping.

Hibernate nastiness filed as bug HHH-2128. When reading this please notice that this situation arose from the most minimal definition. Using the ‘defaults’ is what caused this issue!


  1. define two classes (Primary, Secondary) that have a one-to-one relationship.
  2. use the native generator to generate a primary key for each.
  3. save a primary with no assigned secondary object.
  4. save another primary with a secondary object.
  5. retrieve the first primary and it will have the secondary object saved in previous step.
  6. retrieve the second primary and it will have no secondary object.

Talk about ouch!

This entry was posted in hibernate, technical. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *