Kristina Heckelmann (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMmZhOTBmNGRl...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-15642?atlOrigin=eyJpIjoiMmZhOT...
) HHH-15642 (
https://hibernate.atlassian.net/browse/HHH-15642?atlOrigin=eyJpIjoiMmZhOT...
) ClassCastException saving Entities with ElementCollections loaded from envers (
https://hibernate.atlassian.net/browse/HHH-15642?atlOrigin=eyJpIjoiMmZhOT...
)
Issue Type: Bug Affects Versions: 5.6.12 Assignee: Unassigned Components: hibernate-core
Created: 28/Oct/2022 06:43 AM Priority: Major Reporter: Kristina Heckelmann (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Hello,
after updating Hibernate to 5.6.12 we get the following Exception in one of our test
cases:
java.lang.ClassCastException: class
org.hibernate.envers.internal.entities.mapper.relation.lazy.proxy.SetProxy cannot be cast
to class org.hibernate.collection.spi.PersistentCollection
(org.hibernate.envers.internal.entities.mapper.relation.lazy.proxy.SetProxy and
org.hibernate.collection.spi.PersistentCollection are in unnamed module of loader
'app')
at org.hibernate.type.CollectionType.replace(CollectionType.java:718)
at org.hibernate.type.AbstractType.replace(AbstractType.java:164)
at org.hibernate.type.TypeHelper.replaceAssociations(TypeHelper.java:268)
at
org.hibernate.event.internal.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:476)
at
org.hibernate.event.internal.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:248)
at
org.hibernate.event.internal.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:318)
at
org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:172)
at
org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:70)
at
org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:107)
at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:829)
at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:816)
The test case is restoring an entity after it has been deleted using envers. For that we
load the latest version of the entity with an audit query and save the result using a
repository. Maybe this is not a very common use case, but it worked before.
We only get this problem with Entities that have ElementCollections. For OneToMany
collections the error does not occur - it looks like in that case, the envers proxy is
somehow initialized during save before this code.
I assume, the problem was introduced with the changes of
https://hibernate.atlassian.net/browse/HHH-15522 (
https://hibernate.atlassian.net/browse/HHH-15522 ). Is it possible to add an instanceof
check here or something like that?
(
https://hibernate.atlassian.net/browse/HHH-15642#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-15642#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#100209- sha1:d23b292 )