[hibernate-dev] mutable versus immutable natural keys

Steve Ebersole steve at hibernate.org
Wed Dec 7 10:47:22 EST 2011

There is a 3rd option in regards to immutable... to say that it is 
immutable, requiring a check.

1) mutable
2) immutable (no enforcement)
3) immutable (enforced)

> Would the hint mechanism involve any detection of changed values at all?
>    What would the user see if a natural key were changed?

The other thing that I did not draw out as well as I could, is where 
the value changed.  Did it change as part of the Hibernate Session?  Or 
did the value change in the database.  It is this last bit that we do 
today when the user says immutable, that I dont think should always be 
getting done.  Essentially, we are always checking the database 
snapshot for these entities to make sure this immutable natural key 
value did not change.  I think that specifically should be an 
additional "opt in" behavior.

steve at hibernate.org

More information about the hibernate-dev mailing list