Here, we are talking about the internal state of a value. So, e.g. a String is immutable (we cannot change its internal state) while a Date is mutable (its internal state can be changed). Effectively this tells Hibernate a few important pieces of detail -
- Can we use == for dirty detection, or must we use #equals?
- How do we make copies of those values.
- etc
When an AttributeConverter is in the mix, there is also a big performance impact. Basically anytime we need to make a copy, which happens quite a bit internally, we need to use the converter. So ideally we want to allow users to indicate that a converted attribute should be treated as immutable. Now we already have this capability using @Immutable on the attribute itself. But for repeated conversions (especially auto-applied conversions), that gets tedious. Allow @Immutable to be specified on the converter itself. |