Bart Vansegbroeck (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5be4380...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiY2NjZWM5ZDcx...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16105?atlOrigin=eyJpIjoiY2NjZW...
) HHH-16105 (
https://hibernate.atlassian.net/browse/HHH-16105?atlOrigin=eyJpIjoiY2NjZW...
) Hibernate no longer detects HashMap property with AttributeConverter as dirty (
https://hibernate.atlassian.net/browse/HHH-16105?atlOrigin=eyJpIjoiY2NjZW...
)
Issue Type: Bug Affects Versions: 6.1.6 Assignee: Unassigned Components: hibernate-core
Created: 26/Jan/2023 01:02 AM Environment: Macos, Java17 Priority: Major Reporter: Bart
Vansegbroeck (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5be4380...
)
An entity has a HashMap as property, property is convertered using an AttributeConverter.
After updating the hashmap, the dirty check does not flag this property as dirty and no
update is done.
@Entity
@Table(name = "person")
public class Person {
@Id
private int id;
...
@Convert(converter = HashMapConverter.class)
private Map<String, Object> attributes = new HashMap<>();
...
}
public class HashMapConverter implements AttributeConverter<HashMap<String,
Object>, String> {
private final ObjectMapper mapper = new ObjectMapper();
@Override
public String convertToDatabaseColumn(HashMap<String, Object>
stringObjectHashMap) {
try {
return mapper.writeValueAsString(stringObjectHashMap);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
@Override
public HashMap<String, Object> convertToEntityAttribute(String string) {
try {
return mapper.readValue(string, new TypeReference<>() {});
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
I’ve added a failing test case in hibernate-orm-6 and a working test case with the same
setup in hibernate-orm-5
(
https://hibernate.atlassian.net/browse/HHH-16105#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16105#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100214- sha1:634fa42 )