You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Albert Lee (JIRA)" <ji...@apache.org> on 2009/06/05 18:32:07 UTC

[jira] Commented: (OPENJPA-1120) idEquals() broken in BigDecimalId and BigIntegerId

    [ https://issues.apache.org/jira/browse/OPENJPA-1120?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12716663#action_12716663 ] 

Albert Lee commented on OPENJPA-1120:
-------------------------------------

Need to check if "other" is a BigDecimalId or a subclass of BigDecimalId, otherwise a ClassCastException will occur in the return statement.

       if(key == null || ! BigDecimalId.class.isAssignableFrom(other.getClass())) 
             return false;
 
        return key.equals(((BigDecimalId)other).key);

Albert Lee.

> idEquals() broken in BigDecimalId and BigIntegerId
> --------------------------------------------------
>
>                 Key: OPENJPA-1120
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1120
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.0.0
>            Reporter: dieter von holten
>            Priority: Minor
>             Fix For: 2.0.0
>
>         Attachments: BrokenEqualsId.patch
>
>
> in openjpa/util/BigDecimalId and open/util/BigIntegerId the idEquals-methods compare their own keys to the other object, not to others.key.
> That would always result in false - which is false sometimes

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] Commented: (OPENJPA-1120) idEquals() broken in BigDecimalId and BigIntegerId

Posted by in...@dvholten.de.
yeah, but that is also valid for the other subclasses of OpenJPAId. They 
also just cast -  my patch is in line with that,



Albert Lee commented on OPENJPA-1120:
-------------------------------------

Need to check if "other" is a BigDecimalId or a subclass of BigDecimalId, 
otherwise a ClassCastException will occur in the return statement.

       if(key == null || ! 
BigDecimalId.class.isAssignableFrom(other.getClass())) 
             return false;
 
        return key.equals(((BigDecimalId)other).key);

Albert Lee.

> idEquals() broken in BigDecimalId and BigIntegerId
> --------------------------------------------------
>
>                 Key: OPENJPA-1120
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1120
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.0.0
>            Reporter: dieter von holten
>            Priority: Minor
>             Fix For: 2.0.0
>
>         Attachments: BrokenEqualsId.patch
>
>
> in openjpa/util/BigDecimalId and open/util/BigIntegerId the 
idEquals-methods compare their own keys to the other object, not to 
others.key.
> That would always result in false - which is false sometimes

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.