[hibernate-issues] [JIRA] (HHH-9662) IllegalArgumentException when composite ID has IDENTITY generated value

IT Support (JIRA) jira at hibernate.atlassian.net
Tue Apr 21 11:16:55 EDT 2020


IT Support ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A7c7fc415-3805-43c8-9dfa-7cbe1117db94 ) *commented* on HHH-9662 ( https://hibernate.atlassian.net/browse/HHH-9662?atlOrigin=eyJpIjoiNTk3OWZkYjE1YjlhNGJjYjljYjdkOWU0Mjc0ZjU0ODYiLCJwIjoiaiJ9 )

Re: IllegalArgumentException when composite ID has IDENTITY generated value ( https://hibernate.atlassian.net/browse/HHH-9662?atlOrigin=eyJpIjoiNTk3OWZkYjE1YjlhNGJjYjljYjdkOWU0Mjc0ZjU0ODYiLCJwIjoiaiJ9 )

I have found that this fails with sequences too, when the composite identifier is another entity.

This works:

   @Id
   @Column(name = "registration_number" )
   @GeneratedValue(strategy = GenerationType.SEQUENCE)
   private Long registrationNumber;

   @Id
   @Column(name = "publisher_id" )
   private Integer publisherId;

but, this does not:

   @Id
   @Column(name = "registration_number" )
   @GeneratedValue(strategy = GenerationType.SEQUENCE)
   private Long registrationNumber;

   @Id
   @JoinColumn(name = "publisher_id" )
   @ManyToOne
   private Publisher publisherId;

The exception thrown is:

javax.persistence.PersistenceException: org.hibernate.HibernateException: No part of a composite identifier may be null
	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)
	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188)
	at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:716)
	at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:696)
	at x.Testclass.x(Testclass.java:56)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: org.hibernate.HibernateException: No part of a composite identifier may be null
	at org.hibernate.tuple.entity.AbstractEntityTuplizer$IncrediblySillyJpaMapsIdMappedIdentifierValueMarshaller.getIdentifier(AbstractEntityTuplizer.java:365)
	at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:219)
	at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:5119)
	at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:4819)
	at org.hibernate.engine.internal.ForeignKeys.isTransient(ForeignKeys.java:294)
	at org.hibernate.event.internal.EntityState.getEntityState(EntityState.java:59)
	at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:95)
	at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:55)
	at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:102)
	at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:710)
	... 25 more

( https://hibernate.atlassian.net/browse/HHH-9662#add-comment?atlOrigin=eyJpIjoiNTk3OWZkYjE1YjlhNGJjYjljYjdkOWU0Mjc0ZjU0ODYiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-9662#add-comment?atlOrigin=eyJpIjoiNTk3OWZkYjE1YjlhNGJjYjljYjdkOWU0Mjc0ZjU0ODYiLCJwIjoiaiJ9 )

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.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100125- sha1:a1a1592 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200421/1301be07/attachment.html 


More information about the hibernate-issues mailing list