Georg Echterling (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiN2UzNDEwMDFh...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-15784?atlOrigin=eyJpIjoiN2UzND...
) HHH-15784 (
https://hibernate.atlassian.net/browse/HHH-15784?atlOrigin=eyJpIjoiN2UzND...
) Primitive array as Natural ID causes ClassCastException (
https://hibernate.atlassian.net/browse/HHH-15784?atlOrigin=eyJpIjoiN2UzND...
)
Issue Type: Bug Affects Versions: 6.1.5 Assignee: Unassigned Components: hibernate-core
Created: 30/Nov/2022 02:48 AM Priority: Major Reporter: Georg Echterling (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Annotating a byte[] field with @NaturalId causes a ClassCastException when trying to
persist the entity. This happens because SimpleNaturalIdMapping.validateInternalForm tries
to cast the primitive array to Object[].
class [B cannot be cast to class [Ljava.lang.Object; ([B and [Ljava.lang.Object; are in
module java.base of loader 'bootstrap')
java.lang.ClassCastException: class [B cannot be cast to class [Ljava.lang.Object; ([B and
[Ljava.lang.Object; are in module java.base of loader 'bootstrap')
at
org.hibernate.metamodel.mapping.internal.SimpleNaturalIdMapping.validateInternalForm(SimpleNaturalIdMapping.java:115)
at
org.hibernate.engine.internal.NaturalIdResolutionsImpl.isValidValue(NaturalIdResolutionsImpl.java:507)
at
org.hibernate.engine.internal.NaturalIdResolutionsImpl.cacheResolutionLocally(NaturalIdResolutionsImpl.java:102)
at
org.hibernate.engine.internal.NaturalIdResolutionsImpl.manageLocalResolution(NaturalIdResolutionsImpl.java:170)
at
org.hibernate.action.internal.AbstractEntityInsertAction.handleNaturalIdPreSaveNotifications(AbstractEntityInsertAction.java:197)
at
org.hibernate.action.internal.AbstractEntityInsertAction.<init>(AbstractEntityInsertAction.java:63)
at
org.hibernate.action.internal.EntityInsertAction.<init>(EntityInsertAction.java:58)
at
org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:363)
at
org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:267)
at
org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:173)
at
org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:133)
at
org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:175)
at
org.hibernate.event.internal.DefaultPersistEventListener.persist(DefaultPersistEventListener.java:93)
at
org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:77)
at
org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:54)
at
org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:107)
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:746)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:730)
at
org.hibernate.orm.test.uniquekey.PrimitiveArrayNaturalIdTest.testPersistByteArrayNaturalId(PrimitiveArrayNaturalIdTest.java:33)
(
https://hibernate.atlassian.net/browse/HHH-15784#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-15784#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#100210- sha1:fb625d0 )