Bart Vansegbroeck (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5be4380...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZjI5MzA2MDUy...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16105?atlOrigin=eyJpIjoiZjI5Mz...
) HHH-16105 (
https://hibernate.atlassian.net/browse/HHH-16105?atlOrigin=eyJpIjoiZjI5Mz...
) Hibernate no longer detects HashMap property with AttributeConverter as dirty (
https://hibernate.atlassian.net/browse/HHH-16105?atlOrigin=eyJpIjoiZjI5Mz...
)
Change By: 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.
{noformat}@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);
}
}
}{noformat}
I’ve added a failing test case in orm/ hibernate-orm-6
and a working test case with the same setup in orm/ hibernate-orm-5
test case: [
github|https://github.com/BartVansegbroeck/hhh16105]
(
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 )