Guenther Demetz (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZDJmMDgwZjM2...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16557?atlOrigin=eyJpIjoiZDJmMD...
) HHH-16557 (
https://hibernate.atlassian.net/browse/HHH-16557?atlOrigin=eyJpIjoiZDJmMD...
) NaturalIdCache remains with wrong key-value after create-delete-recreate action (
https://hibernate.atlassian.net/browse/HHH-16557?atlOrigin=eyJpIjoiZDJmMD...
)
Issue Type: Bug Affects Versions: 5.6.13, 6.2.2 Assignee: Unassigned Components:
hibernate-core Created: 05/May/2023 02:03 AM Environment: Normal environment using
2ndLevel-Cache.
Working on entity classes configured for shared cache with StrictReadWrite Access strategy
& NaturalIdCache Labels: CacheConcurrencyStrategy.READ_WRITE NaturalIdCache Priority:
Major Reporter: Guenther Demetz (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) Original estimate: 1h Remaining Estimate: 1h
Precondition: We have an entity class annotated with NaturalIdCache and the choosen
strategy is CacheConcurrencyStrategy.READ_WRITE.
When persisting & deleting such an entity object within the same transaction,
after the commit we remain with an obsolete cache entry (key=<naturalid-value>
value=<primary key>)
If we now create another persistent object with the same naturalId value, this cannot be
resolved anymore from shared cache anymore because the cache entry points to an obsolete
(deleted) primary key.
scope.inTransaction(
(session) -> {
AllCached it = new AllCached( "it" );
session.persist(it);
session.remove(it);
}
);
// now recreate with same naturarId value
scope.inTransaction(
(session) -> {
AllCached it = new AllCached( "it" );
session.persist(it);
}
);
scope.inTransaction(
(session) -> {
final AllCached shouldBeThere = session.bySimpleNaturalId( AllCached.class ).load(
"it" );
assertNotNull( shouldBeThere ); // FAILS!!!!
}
);
For more informations please see upcoming Pullrequest which will contain a testcase and a
fix proposal.
(
https://hibernate.atlassian.net/browse/HHH-16557#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16557#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#100225- sha1:f83bc8f )