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

Key: HHH-2542
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Gail Badner
Reporter: Reto Urfer
Votes: 2
Watchers: 4
Operations

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

NullPointerException in TypeFactory.replaceAssociations for ComponentType

Created: 04/Apr/07 03:47 AM   Updated: 14/Aug/07 02:54 PM
Component/s: core
Affects Version/s: 3.2.3
Fix Version/s: 3.3.0.CR1, 3.2.6

Time Tracking:
Not Specified

File Attachments: 1. Text File HHH-2542.patch (0.9 kb)
2. Zip Archive Hibernate Bug 2542.zip (9 kb)

Issue Links:
Duplicate
 


 Description  « Hide
The following code block will throw a NullPointerException when targetComponentValues should be determines and target[i] contains a NULL value.

else if ( types[i].isComponentType() ) {
// need to extract the component values and check for subtype replacements...
AbstractComponentType componentType = ( AbstractComponentType ) types[i];
Type[] subtypes = componentType.getSubtypes();
Object[] origComponentValues = original[i] == null ? new Object[subtypes.length] : componentType.getPropertyValues( original[i], session );
Object[] targetComponentValues = componentType.getPropertyValues( target[i], session );
replaceAssociations( origComponentValues, targetComponentValues, subtypes, session, null, copyCache, foreignKeyDirection );


This problem can be fixed the same way as it is prevented when origComponentValues are determined (see following line)
Object[] targetComponentValues = target[i] == null ? new Object[subtypes.length] : componentType.getPropertyValues( target[i], session );
copied[i] = target[i];
}


The problem did not exist in Version 3.2.2

 All   Comments   Work Log   Change History   FishEye      Sort Order: Ascending order - Click to sort in descending order
Steve Ebersole - 04/Apr/07 11:43 AM
need a test case reproducing this

Reto Urfer - 05/Apr/07 01:37 PM
Attached zip file contains an eclipse project to reproduce the bug. the example uses hibenate jpa.

Gail Badner - 18/Apr/07 06:22 PM
I believe this is the same issue as HHH-2572. I've added a patch for a simpler test case to that ticket. I am currently testing the fix in this ticket to see if it works for that issue.

Gail Badner - 19/Apr/07 03:48 PM
I believe the suggested fix omits a line and should be as follows:

Object[] targetComponentValues = target[i] == null ? new Object[subtypes.length] : componentType.getPropertyValues( target[i], session );
replaceAssociations( origComponentValues, targetComponentValues, subtypes, session, null, copyCache, foreignKeyDirection );
copied[i] = target[i]

I am attaching a patch with this change for the Hibernate3_2 branch, HHH-2542.patch.

I have verified that the test case in HHH-2572 works properly with this fix and that no other unit tests break.

I have not checked the test case attached to this issue because there were build errors ('ManyToOne' attribute 'ref' cannot be used in Embeddable object) and I wasn't sure of the versions of Annotations and Entity Manager that were being used.

Gail Badner - 14/Aug/07 02:54 PM
Fixed in trunk / 3.2.