[
https://hibernate.onjira.com/browse/HHH-6960?page=com.atlassian.jira.plug...
]
ms commented on HHH-6960:
-------------------------
I too have the same issue. Unable to recreate in unit test but able to in live run.
Couple of notes on my entity:
- not audited, nor directly related to audited entites.
- the offending entity collection is a child of the entity that's being persisted.
- collection entity class has 3 items related back to it through oneToMany relationships.
Their definition is as follows:
@OneToMany(mappedBy = "sourceField", fetch = FetchType.EAGER)
private List<TableMapplet> sourceMapplets;
@OneToMany(mappedBy = "targetField", fetch = FetchType.EAGER)
private List<Mapplet> targetMapplets;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "column", fetch =
FetchType.EAGER)
private List<IndexColumn> indexColumns;
What is occurring in hibernate in steps:
1) "org.hibernate.engine.spi.ActionQueue#executeActions()" is executing
"executeActions( collectionRemovals );" where "collectionRemovals" has
15 items... its those 3 relationship owning entities, mentioned earlier, repeated over
and over again. so cycling through 5 five times. These actions are executed by the
private "executeActions()" method.
2) "org.hibernate.action.internal.CollectionRemoveAction#preRemove()" creates
the event object. It is here where "getPersister()" is called in event
constructor to add the appropriate "loadedPersister" then executes the
listener.
3)
"org.hibernate.envers.event.EnversPreCollectionRemoveEventListenerImpl#onPreRemoveCollection()"
called by (step 2) where it checks for loadedPersister (loaded previously) and determines
if inverse, which is false and continues on for all 3 varying items.
So what is stumping me is that on the 4th iteration the same getPersister() object from
the 1st iteration is used in the event constructor (step 2 from above). All is good.
However, when the code moves into (step 3) "onPreRemoveCollection()"
getLoadedPersister() returns null.
I don't see anything in collectionRemoveAction nor in ActionQueue that could remove it
and obviously it had the object in the 4th iteration. As per the enver's side only
the listener is called as far as i can tell, so no clean up job to follow unless
there's some weaving going on that i don't see.
Any help in resolving this issue would greatly be appreciated. Its a showstopper for me.
NullPointerException in PreCollectionRemove Listener
----------------------------------------------------
Key: HHH-6960
URL:
https://hibernate.onjira.com/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
Assignee: Adam Warski
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