| I believe the disconnect here is that you see the domain model type as immutable, but that Hibernate has no idea if the thing is mutable or immutable (MutabilityPlan). This is information not covered by JPA's AttributeConverter contract. So Hibernate has to choose the safest route - which is that the state is mutable. As quick background, we are talking about the internal state of the type. E.g. the internal state of a Date is mutable (Date#setTime) whereas the internal state of a Integer is not. Hibernate needs to treat those differently for all the cases covered by MutabilityPlan (equality check, cache assembly/disassembly). We have discussed ways to make that more configurable in 6.0 in parallel with defining an AttributeConverter. I am not sure which exact direction this will go yet. But even today there is a "workaround" here: you should be able to manually register a JavaTypeDescriptor that properly defines your domain model type. |