lotabout (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZTJjZDdkODY5...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16335?atlOrigin=eyJpIjoiZTJjZD...
) HHH-16335 (
https://hibernate.atlassian.net/browse/HHH-16335?atlOrigin=eyJpIjoiZTJjZD...
) Regression: wrong dirty check for converter fields under @Transactional causing entity
not saved (
https://hibernate.atlassian.net/browse/HHH-16335?atlOrigin=eyJpIjoiZTJjZD...
)
Change By: lotabout (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
h2. What Happened
Version: spring boot {{3.0.2}} with Hibernate {{6.1. 7 6.Final}}.
With the following simple entity, if we simply put another field to its {{properties}}
field, the entity won’t be saved.
{code:java}@Table
@Entity
public class MetaEntry {
@Id
private String uuid;
@Convert(converter = PropertyConverter.class)
private Map<String, Object> properties;
private String str = "x";
// ...
}{code}
* The entity won’t be saved after calling {{patchProperties}} function.
* If {{@Transactional}} is removed, the entity WILL BE saved.
* If {{@Transactonal}} is kept but another field {{setStr}} is modified, then the entity
WILL BE saved.
{code:java}@Component
public class TestService {
private final MetaRepository metaRepository;
@Autowired
public TestService(MetaRepository metaRepository) {
this.metaRepository = metaRepository;
}
@Transactional // will work if commented
public void patchProperties(String uuid, String key, Object value) {
var meta = metaRepository.findById(uuid).get();
meta.getProperties().put(key, value);
// meta.setStr(key); // will work if uncommented
metaRepository.save(meta);
}
}{code}
Expected Behavior: The entity will be saved under {{@Transactional}} annotation and if
only the {{properties}} gets modified.
h2. What Else
# I’ve tried the same code with spring boot {{2.7.9}} with Hibernate {{5.6.15.Final}} and
all worked fine.
# I’ve tried to debug the process and found that the {{loadedState}} of EntityEntry shares
the same {{HashMap}} object with user’s {{meta.getProperties}}.
h2. Test Case
Run {{mvn test}} after extract the attached file. The test
{{JpaTest1ApplicationTests#test}} will reproduce the issue.
Thanks!
(
https://hibernate.atlassian.net/browse/HHH-16335#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16335#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#100218- sha1:9826a04 )