[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-6960) NullPointerException in PreCollectionRemove Listener

Marek Dominiak (JIRA) noreply at atlassian.com
Fri Jan 20 08:22:11 EST 2012


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6960?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45197#comment-45197 ] 

Marek Dominiak commented on HHH-6960:
-------------------------------------

In our appliaction we have got this exception as well with exactly the same stack trace. I was trying to prepare a test case but unfortunately it seems to be really hard. For all simple cases (simple domain model) exception is not throws, for our complicated case (quite big domain model) this exception is thrown for some use cases when we try to delete complicated set of somehow connected entities. To create test case I would have to copy 50+ classes which was taking too much time. 

I have tried to change the source code to add additional check for null: 


@Override
	public void onPreRemoveCollection(PreCollectionRemoveEvent event) {
        CollectionEntry collectionEntry = getCollectionEntry( event );
        if ( collectionEntry != null && collectionEntry.getLoadedPersister() != null && !collectionEntry.getLoadedPersister().isInverse() ) {
            onCollectionAction( event, null, collectionEntry.getSnapshot(), collectionEntry );
        }
	}

and it seems that this change helped. All entities we want to create revisions for were created. 


Some observations while playing with this issue:
- it does not matter how many times @Autited is used - whether one or many entities/fields are annotated with @Autited I get exactly the same results when running our tests each time, I get no errors only when all of @Audited are commented out. So that could be either: our configuration or the bug which causes the exception under certain circumstances (how our entities are connected with each other etc.)


> NullPointerException in PreCollectionRemove Listener
> ----------------------------------------------------
>
>                 Key: HHH-6960
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6960
>             Project: Hibernate ORM
>          Issue Type: Bug
>          Components: envers
>    Affects Versions: 4.0.0.Final
>         Environment: Hibernate 4.0.0 to MySQL
>            Reporter: Kevin Jordan
>
> I'm getting a NullPointerException on line 47 of EnversPreCollectionRemoveEventListenerImpl very consistently. I wasn't sure if it was due to lazy collections or not, but it seems that it fails if they're eagerly fetched or lazily fetched. I'm guessing it has something to do with getLoadedPersister() returning a null value since the comments for it say "This is only available late during the flush cycle". The stack trace is
> Quote:
> java.lang.NullPointerException
> at org.hibernate.envers.event.EnversPreCollectionRemoveEventListenerImpl.onPreRemoveCollection(EnversPreCollectionRemoveEventListenerImpl.java:47)
> at org.hibernate.action.internal.CollectionRemoveAction.preRemove(CollectionRemoveAction.java:143)
> at org.hibernate.action.internal.CollectionRemoveAction.execute(CollectionRemoveAction.java:104)
> at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:273)
> at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:265)
> at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:188)
> at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:323)
> at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
> at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1081)
> at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:315)
> 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)
> ... 120 more

--
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