[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-2542) NullPointerException in TypeFactory.replaceAssociations for ComponentType

Gail Badner (JIRA) noreply at atlassian.com
Thu Apr 19 16:49:04 EDT 2007


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2542?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gail Badner updated HHH-2542:
-----------------------------

    Attachment: HHH-2542.patch

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.

> NullPointerException in TypeFactory.replaceAssociations for ComponentType
> -------------------------------------------------------------------------
>
>                 Key: HHH-2542
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2542
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.3
>            Reporter: Reto Urfer
>         Attachments: HHH-2542.patch, Hibernate Bug 2542.zip
>
>
> 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

-- 
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