Change By: Brett Meyer (24/Oct/12 9:49 PM)
Description: With TRACE level logging enabled  the log statement for an orphaned one-to-one delete results in an exception due to entity references being mixed up. In the code below from org.hibernate.engine.internal.Cascade.cascadeProperty(Cascade.java:258) the entity variable is an EntityEntry for the parent object but loadedValue is the instance of the now-orphaned child object.

{code}
if ( LOG.isTraceEnabled() ) {
final Serializable id = entry.getPersister().getIdentifier( loadedValue
,  eventSource );
final String description = MessageHelper.infoString( entityName, id );
LOG.tracev( "Deleting orphaned entity instance: {0}", description );
}
{code}

The resulting stack trace looks like:
{noformat}
org.springframework.orm.hibernate3.HibernateSystemException: could not get a field value by reflection getter of org.jasig.portal.events.aggr.tab.TabRenderAggregationImpl.id; nested exception is org.hibernate.PropertyAccessException: could not get a field value by reflection getter of org.jasig.portal.events.aggr.tab.TabRenderAggregationImpl.id
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:690)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:104)
at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:516)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:147)
at org.jasig.portal.
 numerous test  failures occur . BaseJpaDaoTest$2.call(BaseJpaDaoTest.java   Most are due to : 146)
at org.jasig.portal.test.BaseJpaDaoTest$MethodInvocationCallable.proceed(BaseJpaDaoTest.java:214)
at org.springframework.orm.jpa.JpaInterceptor.invoke(JpaInterceptor.java:101)
at org.jasig.portal.test.BaseJpaDaoTest.execute(BaseJpaDaoTest.java:126)
at org.jasig.portal.test.BaseJpaDaoTest.executeInTransaction(BaseJpaDaoTest.java:143)
at org.jasig.portal.events.aggr.JpaBaseAggregationDaoTest.testBaseAggregationLifecycle(JpaBaseAggregationDaoTest.java:209)
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:597)
at org.junit.runners.model.FrameworkMethod$
1. runReflectiveCall(FrameworkMethod.java:45 )
at org
 Usage of property-refs affects collection keys . junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.
  Many logging statements  incorrectly assume that collection keys are owner Ids . InvokeMethod.evaluate(InvokeMethod.java:20)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$
2. evaluate(ParentRunner.java:222 )
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of org.jasig.portal.events.aggr.tab.TabRenderAggregationImpl.id
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:61)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:341)
at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:4260)
at org.hibernate.engine.internal.Cascade.cascadeProperty(Cascade.java:258)
at org.hibernate.engine.internal.Cascade.cascade(Cascade.java:165)
at org.hibernate.event.internal.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:160)
at org.hibernate.event.internal.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:151)
at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:88)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
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)
at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:512)
... 38 more
Caused by: java.lang.IllegalArgumentException: Can not set final long field org.jasig.portal.events.aggr.tab.TabRenderAggregationImpl.id
 Cascading logging on orphaned one-  to  org.jasig.portal.events.aggr.JpaStatisticalSummary -one entities
at sun 3 . reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146 )
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37)
at sun.reflect.UnsafeQualifiedLongFieldAccessorImpl.getLong(UnsafeQualifiedLongFieldAccessorImpl.java:44)
at sun.reflect.UnsafeQualifiedLongFieldAccessorImpl.get(UnsafeQualifiedLongFieldAccessorImpl.java:20)
at java.lang.reflect.Field.get(Field.java:358)
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:58)
... 52 more
{noformat}
 Incorrect handling of HibernateProxy Ids
Pull Requests: https://github.com/hibernate/hibernate-orm/pull/343
Summary: Cascade mixes entity references in trace Trace  logging  of orphan delete  causes numerous test errors
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira