[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2146) NullpointerException in DefaultDeleteEventListener.deleteTransientEntity

Ashley Tate (JIRA) noreply at atlassian.com
Fri Jan 19 13:49:44 EST 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2146?page=comments#action_25861 ] 

Ashley Tate commented on HHH-2146:
----------------------------------

I've duplicated this bug in 3.2.1 GA . The stack trace is below. The source of the problem is in org.hibernate.engine.Cascade.deleteOrphans() on this line:

<<
eventSource.delete( entityName, orphan, false, null );
>>

EventSource.delete(String, Object, boolean, Set) should be called with an empty Set parameter rather than null. Hopefully this info will suffice, otherwise let me know if you still need a test case.

Regards,
Ashley Tate


============================================
SOURCE OF ERROR: 

>From org.hibernate.engine.Cascade:

	private void deleteOrphans(String entityName, PersistentCollection pc) throws HibernateException {
		//TODO: suck this logic into the collection!
		final Collection orphans;
		if ( pc.wasInitialized() ) {
			CollectionEntry ce = eventSource.getPersistenceContext().getCollectionEntry(pc);
			orphans = ce==null ?
					CollectionHelper.EMPTY_COLLECTION :
					ce.getOrphans(entityName, pc);
		}
		else {
			orphans = pc.getQueuedOrphans(entityName);
		}

		final Iterator orphanIter = orphans.iterator();
		while ( orphanIter.hasNext() ) {
			Object orphan = orphanIter.next();
			if (orphan!=null) {
				if ( log.isTraceEnabled() ) {
					log.trace("deleting orphaned entity instance: " + entityName);
				}
				eventSource.delete( entityName, orphan, false, null );
			}
		}
	}

=======================================
ERROR STACK TRACE:

java.lang.NullPointerException
	at org.hibernate.event.def.DefaultDeleteEventListener.deleteTransientEntity(DefaultDeleteEventListener.java:162)
	at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:70)
	at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:775)
	at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:758)
	at org.hibernate.engine.Cascade.deleteOrphans(Cascade.java:355)
	at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:324)
	at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)
	at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)
	at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
	at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
	at org.hibernate.event.def.DefaultDeleteEventListener.cascadeBeforeDelete(DefaultDeleteEventListener.java:274)
	at org.hibernate.event.def.DefaultDeleteEventListener.deleteEntity(DefaultDeleteEventListener.java:213)
	at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:128)
	at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:49)
	at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:766)
	at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:744)
	at org.springframework.orm.hibernate3.HibernateTemplate$25.doInHibernate(HibernateTemplate.java:785)
	at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:367)
	at org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:779)
	at org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:775)
	at com.mckesson.common.orm.hibernate.HibernateDaoSupport.deleteObject(HibernateDaoSupport.java:59)
	at com.mckesson.common.eo2.eo.CustomerHibernateDao.delete(CustomerHibernateDao.java:22)
	at com.mckesson.common.eo2.BookstoreHibDaoApiTest.testCreateCustomer1(BookstoreHibDaoApiTest.java:351)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at junit.framework.TestCase.runTest(TestCase.java:164)
	at com.mckesson.common.junit.TestCase.runTest(TestCase.java:426)
	at junit.framework.TestCase.runBare(TestCase.java:130)
	at com.mckesson.common.junit.TestCase.runBare(TestCase.java:415)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:120)
	at junit.framework.TestSuite.runTest(TestSuite.java:228)
	at junit.framework.TestSuite.run(TestSuite.java:223)
	at junit.framework.TestSuite.runTest(TestSuite.java:228)
	at junit.framework.TestSuite.run(TestSuite.java:223)
	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:297)
	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:672)
	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:567)

> NullpointerException in DefaultDeleteEventListener.deleteTransientEntity
> ------------------------------------------------------------------------
>
>          Key: HHH-2146
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2146
>      Project: Hibernate3
>         Type: Bug

>     Versions: 3.2.0.cr5
>  Environment: Hibernate 3.2.0cr5, Oracle10g
>     Reporter: Martin Kartumovich
>     Priority: Minor

>
>
> The following setup leads to a NPE in DefaultDeleteEventListener.deleteTransientEntity:
> Tables A, B
> Table V_A_B that is an M-N-Connection between A and B.
> Pojo for A has a Set of V_A_Bs.
> Pojo for B has a Set of V_A_Bs.
> Pojo C that has Sets of As and Bs.
> Cascades: all, delete-orphan
> -Create a new A and add a new V_A_B to its Set, that references to an existing B.
> -Delete B.
> -SaveOrUpdate Pojo C.
> In Hibernate 3.1.3 this works fine.
> In 3.2.0cr4+cr5 the removal of B results into an cascading removal of the never persisted V_A_B in the Set of B instead of ignoring it.
> This leads to an incorrect state where deleteTransientEntity is called with transientEnties=null.
> When now calling transientEnties.contains(...) the NPE is thrown.

-- 
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.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list