Christian Beikov (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiODgxYjg5MWQz...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16025?atlOrigin=eyJpIjoiODgxYj...
) HHH-16025 (
https://hibernate.atlassian.net/browse/HHH-16025?atlOrigin=eyJpIjoiODgxYj...
) Using BatchEntitySelectFetchInitializer with caching leads to caching wrong values (
https://hibernate.atlassian.net/browse/HHH-16025?atlOrigin=eyJpIjoiODgxYj...
)
Issue Type: Bug Affects Versions: 6.2.0.CR1, 6.1.6 Assignee: Unassigned Components:
hibernate-core Created: 11/Jan/2023 07:28 AM Priority: Major Reporter: Christian Beikov (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Coming from this Discourse discussion (
https://discourse.hibernate.org/t/entity-put-into-second-level-cache-with...
) , the problem is when using second level caching along with @BatchSize , because cache
entries are put into the cache, before the BatchEntitySelectFetchInitializer for an
association set the value on the owning entity, so the cache entry contains null for the
association which is wrong. Reading from the cache later leads to materializing wrong
data.
@Entity
@BatchSize(10)
@Cacheable
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
class Parent {
@Id
Long id;
@ManyToOne
Child c;
}
@Entity
@Cacheable
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
class Child {
@Id
Long id;
String name;
}
(
https://hibernate.atlassian.net/browse/HHH-16025#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16025#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#100213- sha1:b01baad )