[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-7085) Entities marked as @Immutable that have a @NaturalId fail to be inserted with NPE

Eric Dalquist (JIRA) noreply at atlassian.com
Mon Feb 20 09:52:12 EST 2012


    [ https://hibernate.onjira.com/browse/HHH-7085?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45560#comment-45560 ] 

Eric Dalquist commented on HHH-7085:
------------------------------------

Unit test that demonstrates the bug: https://github.com/edalquist/hibernate-core/commit/c4b816f3dda39b51827999913f34d613b2d1ff68

> Entities marked as @Immutable that have a @NaturalId fail to be inserted with NPE
> ---------------------------------------------------------------------------------
>
>                 Key: HHH-7085
>                 URL: https://hibernate.onjira.com/browse/HHH-7085
>             Project: Hibernate ORM
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 4.1.0
>            Reporter: Eric Dalquist
>
> Due to the work done for HHH-6974 inserting an @Immutable entity with a @NaturalId results in a NullPointerException
> The cause appears to be due to read-only entities not having EntityEntry.getLoadedState() populated upon insert and StatefulPersistenceContext.getNaturalIdValues assumes that array will not be null.
> {noformat}
> Caused by: java.lang.NullPointerException
> 	at org.hibernate.engine.internal.StatefulPersistenceContext.getNaturalIdValues(StatefulPersistenceContext.java:1755)
> 	at org.hibernate.engine.internal.StatefulPersistenceContext.loadedStateInsertedNotification(StatefulPersistenceContext.java:1715)
> 	at org.hibernate.engine.spi.EntityEntry.notifyLoadedStateInserted(EntityEntry.java:390)
> 	at org.hibernate.engine.spi.EntityEntry.postInsert(EntityEntry.java:266)
> 	at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:95)
> 	at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:362)
> 	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:354)
> 	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:275)
> 	at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:326)
> 	at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
> 	at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1127)
> 	at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:325)
> 	at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
> 	at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:175)
> 	at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:73)
> 	... 54 more
> {noformat}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list