[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3847?page=c...
]
Adam Warski commented on HHH-3847:
----------------------------------
From the forum:
Hello,
above mentioned exception also occurs in following scenario:
Entity A has many-to-many relationship to Entity B
Code:
A a = new A()
Set setOfB = new HashSet<B>();
setOfB.add(new B());
a.setB(setOfB);
save(a);
a.setB(new Hashset<B>()); // clear set of B in A
update(a);
following version works though:
Code:
A a = new A()
Set setOfB = new HashSet<B>();
setOfB.add(new B());
a.setB(setOfB);
save(a);
a.getB().clear; // clear set of B in A
update(a);
java.lang.NullPointerException on onPreRemoveCollection on replicate
of persistent class
----------------------------------------------------------------------------------------
Key: HHH-3847
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3847
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.3.1
Environment: Envers 1.2, Hibernate 3.3.1 on Mysql and Hsql.
Reporter: Francesco Di Salvatore
Priority: Critical
Attachments: TestEnvers12.zip
I get this exception when trying to REPLICATE an object in a synchronized database:
Code:
DEBUG [main] (CodeSystemDAOHibernate.java:131) - java.lang.NullPointerException
at
org.hibernate.envers.event.AuditEventListener.onPreRemoveCollection(AuditEventListener.java:235)
at
org.hibernate.action.CollectionRemoveAction.preRemove(CollectionRemoveAction.java:134)
at org.hibernate.action.CollectionRemoveAction.execute(CollectionRemoveAction.java:100)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:169)
at
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventLis
tener.java:321)
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
at
com.phi.dictionarymanager.logic.hibernate.GenericDAOHibaernate.commitNetwork(GenericDAOHibaernate
.java:183)
at
com.phi.dictionarymanager.logic.hibernate.CodeSystemDAOHibernate.save(CodeSystemDAOHibernate.jav
a:92)
at
com.phi.dictionarymanager.ui.widgets.VocabolaryItemNewComposite.save(VocabolaryItemNewComposite.
java:515)
at
com.phi.dictionarymanager.ui.widgets.VocabularyDomainsNavigatorComposite$18.handleEvent(Vocabula
ryDomainsNavigatorComposite.java:1434)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.j
ava:106)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
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.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
at org.eclipse.equinox.launcher.Main.main(Main.java:1148)
Code throwing the exception:
Code:
beginTransactionLocal();
makePersistentLocal(cs);
commitLocal();
closeSessionLocal();
beginTransactionNetwork();
makePersistentNetwork(cs);
commitNetwork();
closeSessionNetwork();
For this insertion of the object cs, the makePersistentLocal makes a saveOrUpdate call,
while makePersistentNetwork calls replicate(cs, ReplicateMode.LATEST_VERSION).
My hibernate-mysql.cfg.xml and hibernate-hsql.cfg.xml are very similar (I post only the
mysql one):
Code:
<hibernate-configuration>
<session-factory>
...
<property
name="org.hibernate.envers.revisionOnCollectionChange">true</property>
<property
name="org.hibernate.envers.doNotAuditOptimisticLockingField">true</property>
<!-- HIBERNATE BEAN MAPPINGS -->
<mapping
resource="com/phi/dictionarymanager/beans/CodeEquivalent.hbm.xml" />
<mapping
resource="com/phi/dictionarymanager/beans/CodeValue.hbm.xml" />
<mapping
resource="com/phi/dictionarymanager/beans/CodeTranslation.hbm.xml" />
<mapping
resource="com/phi/dictionarymanager/beans/CodeSystem.hbm.xml" />
<event type="post-insert">
<listener class="org.hibernate.envers.event.AuditEventListener"
/>
</event>
<event type="post-update">
<listener class="org.hibernate.envers.event.AuditEventListener"
/>
</event>
<event type="post-delete">
<listener class="org.hibernate.envers.event.AuditEventListener"
/>
</event>
<event type="pre-collection-update">
<listener class="org.hibernate.envers.event.AuditEventListener"
/>
</event>
<event type="pre-collection-remove">
<listener class="org.hibernate.envers.event.AuditEventListener"
/>
</event>
<event type="post-collection-recreate">
<listener class="org.hibernate.envers.event.AuditEventListener"
/>
</event>
</session-factory>
</hibernate-configuration>
All the collections in this project are in mode lazy="true".
In the first saving the onPreRemoveCollection method is never called.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira