William Rosenquist Burns (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5a7b38f...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYjU5MGQ2MjYy...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16033?atlOrigin=eyJpIjoiYjU5MG...
) HHH-16033 (
https://hibernate.atlassian.net/browse/HHH-16033?atlOrigin=eyJpIjoiYjU5MG...
) Many-to-Many inverse mapping referencing the same class uses pk instead of fk field for
removal (
https://hibernate.atlassian.net/browse/HHH-16033?atlOrigin=eyJpIjoiYjU5MG...
)
Change By: William Rosenquist Burns (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5a7b38f...
)
While updating Infinispan 2LC to use Hibernate 6.2.0 from 6.0.2 we found a regression with
how many to many mappings do a removal. It seems to be trying to use the primary key
identifier instead of the foreign key field. This is a problem for a test as the primary
key is a Long and the foreign key is a String.
This causes a ClassCastException when it tries to remove any many-to-many mappings that
may exist.
{noformat} <bag name="bagOfItems" inverse="true"
table="items_otheritems">
<key column="other_item_id"/>
<many-to-many class="Item" property-ref="name"
column="item_name" />
</bag>{noformat}
This mapping is the underlying cause.
The test just creates an entity in one session, then in a second loads it and removes it,
quite simple. PR will be attached after.
The stack trace is as follows from the
[
PR|https://github.com/hibernate/hibernate-orm/pull/5945]
{noformat}java.lang.ClassCastException: class java.lang.Long cannot be cast to class
java.lang.String (java.lang.Long and java.lang.String are in module java.base of loader
'bootstrap')
at org.hibernate.type.descriptor.java.StringJavaType.unwrap(StringJavaType.java:27)
at org.hibernate.type.descriptor.jdbc.VarcharJdbcType$1.doBind(VarcharJdbcType.java:110)
at org.hibernate.type.descriptor.jdbc.BasicBinder.bind(BasicBinder.java:61)
at
org.hibernate.engine.jdbc.mutation.internal.JdbcValueBindingsImpl.lambda$beforeStatement$0(JdbcValueBindingsImpl.java:87)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at
org.hibernate.engine.jdbc.mutation.spi.BindingGroup.forEachBinding(BindingGroup.java:51)
at
org.hibernate.engine.jdbc.mutation.internal.JdbcValueBindingsImpl.beforeStatement(JdbcValueBindingsImpl.java:85)
at
org.hibernate.engine.jdbc.mutation.internal.AbstractMutationExecutor.performNonBatchedMutation(AbstractMutationExecutor.java:93)
at
org.hibernate.engine.jdbc.mutation.internal.MutationExecutorSingleNonBatched.performNonBatchedOperations(MutationExecutorSingleNonBatched.java:40)
at
org.hibernate.engine.jdbc.mutation.internal.AbstractMutationExecutor.execute(AbstractMutationExecutor.java:43)
at
org.hibernate.persister.collection.mutation.RemoveCoordinatorStandard.deleteAllRows(RemoveCoordinatorStandard.java:113)
at
org.hibernate.persister.collection.AbstractCollectionPersister.remove(AbstractCollectionPersister.java:1124)
at
org.hibernate.action.internal.CollectionRemoveAction.execute(CollectionRemoveAction.java:112)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:616)
at org.hibernate.engine.spi.ActionQueue.lambda$executeActions$1(ActionQueue.java:487)
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:484)
at
org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:329)
at
org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:58)
at
org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:107)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1403)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:476)
at
org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:2269)
at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:1933)
at
org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:426)
at
org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:169)
at
org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:267)
at
org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:101)
at
org.hibernate.testing.orm.transaction.TransactionUtil.wrapInTransaction(TransactionUtil.java:54)
at
org.hibernate.testing.orm.transaction.TransactionUtil.inTransaction(TransactionUtil.java:24)
at
org.hibernate.testing.orm.junit.SessionFactoryExtension$SessionFactoryScopeImpl.inTransaction(SessionFactoryExtension.java:375)
at
org.hibernate.testing.orm.junit.SessionFactoryExtension$SessionFactoryScopeImpl.inTransaction(SessionFactoryExtension.java:352)
at
org.hibernate.orm.test.manytomanyassociationclass.nestedreference.ItemSelfReferenceTest.testSimpleCreateAndDelete(ItemSelfReferenceTest.java:31){noformat}
(
https://hibernate.atlassian.net/browse/HHH-16033#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16033#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#100214- sha1:b03f6a4 )