lotabout (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMGNmMjJjZTE5...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16335?atlOrigin=eyJpIjoiMGNmMj...
) HHH-16335 (
https://hibernate.atlassian.net/browse/HHH-16335?atlOrigin=eyJpIjoiMGNmMj...
) Regression: wrong dirty check for converter fields under @Transactional causing entity
not saved (
https://hibernate.atlassian.net/browse/HHH-16335?atlOrigin=eyJpIjoiMGNmMj...
)
Issue Type: Bug Affects Versions: 6.1.7 Assignee: Unassigned Attachments:
jpa-test-1.tar.gz Components: hibernate-core, regression Created: 17/Mar/2023 19:52 PM
Priority: Major Reporter: lotabout (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
-------------
What Happened
-------------
Version: spring boot 3.0.2 with Hibernate 6.1.7.Final.
With the following simple entity, if we simply put another field to its properties field,
the entity won’t be saved.
@Table
@Entity
public class MetaEntry {
@Id
private String uuid;
@Convert(converter = PropertyConverter.class)
private Map< String , Object > properties;
private String str = "x" ;
// ...
}
* 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.
@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);
}
}
Expected Behavior: The entity will be saved under @Transactional annotation and if only
the properties gets modified.
---------
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.
---------
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 )