[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2626?page=c...
]
Michael Plöd commented on HHH-2626:
-----------------------------------
Are there any news from the Hibernate Team regarding this path. IMHO this bug hurts quite
a bit.
If you need any further assistance / data from my side, please let me know.
Cheers,
Mike
Bug in handling null references to Components / Embeddables when
using session / entityManager.merge()
------------------------------------------------------------------------------------------------------
Key: HHH-2626
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2626
Project: Hibernate3
Issue Type: Patch
Affects Versions: 3.2.3, 3.2.4, 3.2.4.sp1
Environment: Hibernate 3.2.3 - 3.2.4.sp1; Any Database
Reporter: Michael Plöd
Priority: Critical
Attachments: patch.txt, TestCase.zip
I found a bug, that got introduced by adding functionality to the class TypeFactory in
Hibernate 3.2.3. The Method TypeFactory#replaceAssociations(...) now has some special
handling regarding components / embeddables. But if such a component is null, wich is fair
enough, Hibernate will provoke a NullPointerException in
sun.reflect.UnsafeFieldAccessorImpl.ensureObj(...):
Exception in thread "main" javax.persistence.PersistenceException:
org.hibernate.PropertyAccessException: could not get a field value by reflection getter of
de.ploed.test.MonetaryAmount.amount
at
org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:647)
at
org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:236)
at de.ploed.test.EntityManagerTest.main(EntityManagerTest.java:22)
Caused by: org.hibernate.PropertyAccessException: could not get a field value by
reflection getter of de.ploed.test.MonetaryAmount.amount
at
org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:35)
at
org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValue(AbstractComponentTuplizer.java:64)
at
org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValues(AbstractComponentTuplizer.java:70)
at
org.hibernate.tuple.component.PojoComponentTuplizer.getPropertyValues(PojoComponentTuplizer.java:83)
at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:353)
at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:348)
at org.hibernate.type.TypeFactory.replaceAssociations(TypeFactory.java:556)
at
org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:366)
at
org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:195)
at
org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:123)
at
org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:53)
at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:677)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:661)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:665)
at
org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:227)
... 1 more
Caused by: java.lang.NullPointerException
at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:36)
at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18)
at java.lang.reflect.Field.get(Field.java:357)
at
org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:32)
... 15 more
I think that the handling of target[i] in Line 556 of org.hibernate.type.TypeFactory is
not null safe. I have created a patch for this and the bug above appears to be fixed in
this patch.
In my humble opinion this bug makes it impossible to merge any entity / value object
containing a null reference to another value object.
However this bug is not present when using session.save or session.saveOrUpdate.
I was able to reproduce the bug in Hibernate Core 3.2.4.sp1, 3.2.4 and 3.2.3 .. It is not
present in Hibernate Core Versions <= 3.2.2
Attached to this task are the following files:
patch.txt - my patch proposal
TestCase.zip - Test Case
Please get back to me if you have any further questions!
Cheers,
Mike
--
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