[hibernate-issues] [Hibernate-JIRA] Resolved: (HHH-7158) Regression: null values on NaturalId's at persist-time are causing subsequent NPE's and wrong behaviour

Steve Ebersole (JIRA) noreply at atlassian.com
Wed Mar 14 14:38:50 EDT 2012


     [ https://hibernate.onjira.com/browse/HHH-7158?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Steve Ebersole resolved HHH-7158.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 4.1.2

> Regression: null values on NaturalId's at persist-time are causing subsequent NPE's and wrong behaviour
> -------------------------------------------------------------------------------------------------------
>
>                 Key: HHH-7158
>                 URL: https://hibernate.onjira.com/browse/HHH-7158
>             Project: Hibernate ORM
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 4.1.1
>         Environment: Hibernate 4.1.1, db-indipendent (hsqldb used in testcase)
>            Reporter: Guenther Demetz
>            Assignee: Steve Ebersole
>              Labels: naturalId
>             Fix For: 4.1.2
>
>         Attachments: TestCasePersistNullNaturalId.jar
>
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> Since Hibernate 4.1.1 it is no more possible to have uninitialized NaturalId values when persisting, 
> in older versions this was always possible (it was even possible to search NaturalId by null-values).
> The problem stays in the new method NaturalIdXrefDelegate$NaturalIdResolutionCache#areSame(...) 
> where org.hibernate.type.Type#compare(...) is used instead of org.hibernate.type.Type#isEqual(...)
> Proposed solution (method NaturalIdResolutionCache#areSame): 
> if ( !naturalIdTypes[i].isEqual(naturalIdValues[i], values[i], factory)) {
> 	return false;
> }
> instead of: 
> if ( naturalIdTypes[i].compare( naturalIdValues[i], values[i] ) != 0 ) {
>    return false;
> }
> This makes the first test-case green (see attached Testcase).
> The second test-case becomes green, due making method EntityType#isEqual(Object x, Object y, SessionFactoryImplementor factory) 
> stable against null x,y values. That sould be trivial.
> N.B.: Please consider also that the EntityType#compare(Object x, Object y) implementation currently always returns 0 (there's a TODO-note),
>       whilst EntityType#isEqual(Object x, Object y, SessionFactoryImplementor factory) seems to be a good implementation.
> Last but not least: isEqual methods should also be a little bit faster than compare-method, cause the latter must calculate differences.
>       

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list