I do not want to use the primary key of my user table to reference a row from a user interface.
So I wanted to add a public_id column generated (from an oracle sequence) on create, never updated, unique, non-nullable. However @Generated may only be used on @Id columns (
http://opensource.atlassian.com/project ... e/HHH-2907).
I've seen someone offer the workaround of a one-to-one relationship. I can create a public_id to user_id join table with the public_id as @Id,@Generated and put a one-to-one inside the user table. If I then add a non-insert, non-update property while keeping the one-to-one lazy, I can fetch without the overhead of an additional join. However, non-nullability and foreign-key constraints are an issue at creation time. Which comes first, the map table or the user table and how do you enforce data integrity without creating them both at the same time (non-nullability constraint)?
Does anyone know of any way to do this with hibernate?