Dirty Checking on Map for HStore Type
See original GitHub issueHi,
I have an HStore typed Map<String,String> for hibernate5 module.
if I only update the content of the map, the entity is not dirty tracked and appears clean, and is not persisted on update.
I’ve tried to add this scenario to the test case for this hibernate v5 module but I can’t get the repo to compile as-is (mvn toolchains and other dependencies not found)
The hashCode and equals on my entity works fine - I have tests that demonstrates hashcode changes upon map content changes and equals also breaks when only the map changes.
As a workaround, I have the following Entity property
@Entity
public class MyEntity {
...
private int version;
// getters and setters omitted. Note this does not use the @Version annotation.
}
Then (As I’m doing my own audit logging, I know when a change has occurred I can do the following:
if ( mergeUpdated ) {
myEntity.setVersion(myEntity.getMapProp().hashcode());
}
This statement makes the entity itself dirty and is persisted as expected.
I don’t know if this is something that can be adjusted by this library? I’ve no idea how much of hibernate’s instrumentation is in the Map implementation it provides after loading an entity and whether or not that can be forced to check a different way.
Thanks
Rob
Issue Analytics
- State:
- Created a year ago
- Comments:8 (4 by maintainers)

Top Related StackOverflow Question
Sure thing. Check out this article.
No worries. In the meanwhile, you could switch to a
jsonbcolumn and persist theMapattribute to it.