When inside a transaction, using optimistic locking, an entity with this property:
@Type(JsonBinaryType::class)
@Column(name = "errors")
var verrors: Map<String, List<Error>> = emptyMap()
the object revision on DB is always raised if there is content.
Strange is, that this only happens, when also inside a session-in-view coming from controller. Not when called directly.
Using Hibernate 6.3, hypersistence-utils-hibernate-63:3.7.0, Spring Boot 3.2.
After further analysis the root cause is that Hibernate finds the property to be dirty due to comparing the "old" string-only DB-saved Map-List structure with the "new" object-based structure (i.e. there is an Error object as value) in the session.
Expected: Object should not be updated. This is e.g. the case when making the transaction readOnly.
It seems that Hypersistence Utils can only map simple Map<String,String> since the suggestion to implement equals/hashCode didn't also help.
After further research the solution is pretty simple, since Hibernate 6 supports this finally. So no need for Hypersistence Utils - just use:
and it works also for complex structures like this.