History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: HHH-2572
Type: Bug Bug
Status: Closed Closed
Resolution: Duplicate
Priority: Critical Critical
Assignee: Gail Badner
Reporter: Nguyen Hau Giang
Votes: 5
Watchers: 7
Operations

If you were logged in you would be able to see more operations.
Hibernate Core

NullPointerException when cascade-merge detached entity graph that contains null component property

Created: 16/Apr/07 11:23 PM   Updated: 14/Aug/07 04:48 PM
Component/s: core
Affects Version/s: 3.2.3
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments: 1. Text File HHH-2572-testcase-corrected.patch (4 kb)
2. Text File HHH-2572.patch (4 kb)
3. Zip Archive testCase.zip (8 kb)

Environment: hibernate 3.2.3 only
Issue Links:
Duplicate
 


 Description  « Hide
when merging detached entity graph whose leaf-entity contains null-component property, hibernate 3.2.3 will throw NPE. (leaf-entity level>2)
No exception was thrown in hibenate 3.2.2

Mapping:
Parent -> Child -> GrandChild

All associations is cascade.
GrandChild contains a component property.

Test Case:
parent=<load>;
child=parent.get1Child();

GrandChild grandChild=new GrandChild();
grandChild.setComponent(null);
child.add(grandChild);

evict(parent);//session is closed
...
merge(parent);//merge in new sesson -> THROW NullPointerException

for further detail, see attache test case.



 All   Comments   Work Log   Change History   FishEye      Sort Order: Ascending order - Click to sort in descending order
Gail Badner - 18/Apr/07 06:19 PM
I believe this is the same issue as HHH-2542.

I am attaching a patch for a new test to be added to org.hibernate.test.component/basic/ComponentTest.testMergeComponent(), based on the test case provided by Nguyen Hau Giang.

I added the following to Employee:
- an optional component, optionalComponent;
- a Set of Employee objects, directReports.

NullPointerException is thrown when a detached Employee is merged with new element added to directReports that has a null OptionalComponent. Note that this exception is thrown when the child element has a null component, as opposed to the grandchild element as reported earlier.

The stack trace is as follows:
java.lang.NullPointerException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:145)
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:535)
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.impl.SessionImpl.fireMerge(SessionImpl.java:687)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:669)
at org.hibernate.engine.CascadingAction$6.cascade(CascadingAction.java:245)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296)
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.DefaultMergeEventListener.cascadeOnMerge(DefaultMergeEventListener.java:407)
at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:266)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:120)
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.test.component.basic.ComponentTest.testMergeComponent(ComponentTest.java:228)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.hibernate.junit.functional.FunctionalTestCase.runTest(FunctionalTestCase.java:101)
at org.hibernate.junit.UnitTestCase.runBare(UnitTestCase.java:34)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)

I am currently testing the fix provided in HHH-2542 to see if it resolves this issue.

Gail Badner - 19/Apr/07 03:25 PM
I forgot to add a test file to HHH-2572.patch, so I'm attaching a corrected file, HHH-2572-testcase-corrected.patch . HHH-2572.patch can be disregarded.

The fix suggested in HHH-2542 (with a correction) fixed this issue and I verified that it did not break any unit tests. I will attach a patch for the fix to that issue.

Nguyen Hau Giang - 14/May/07 07:30 PM
Thanks a lot,
The patch passed my test case, too.
why this issue is not fixed in version 3.2.4 ?

Kenny MacLeod - 02/Aug/07 06:09 AM
Not fixed in 3.2.5, either. We're currently stuck on 3.2.2 until this is fixed.

Gail Badner - 06/Aug/07 05:43 PM
I'm closing this ticket as a duplicate of HHH-2542, which is scheduled to be fixed for 3.3 and 3.2.6.