db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andy Jefferson (JIRA)" <j...@apache.org>
Subject [jira] Commented: (JDO-466) Test for compound identity fails
Date Mon, 19 Feb 2007 10:23:05 GMT

    [ https://issues.apache.org/jira/browse/JDO-466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12474120
] 

Andy Jefferson commented on JDO-466:
------------------------------------

The PK class for the OrderItem has an incorrect equals() method. It uses "==" but should use
equals() ... like this

public boolean equals(Object obj) {
    if (obj==null || !this.getClass().equals(obj.getClass())) 
        return false;
    OrderItemOid o = (OrderItemOid) obj;
    if ((!this.order.equals(o.order)) || (this.item != o.item)) {
        return false;
    }
    return true;
}

The use of == means that when performing reachability checks JPOX tries to remove all reachables
from the collection of newly persisted object ids and fails to remove the OrderItem ... hence
it gets deleted by reachability. Changing the equals() as above passes the test :-)

> Test for compound identity fails
> --------------------------------
>
>                 Key: JDO-466
>                 URL: https://issues.apache.org/jira/browse/JDO-466
>             Project: JDO
>          Issue Type: Bug
>          Components: tck2
>    Affects Versions: JDO 2 maintenance release 1
>            Reporter: Michelle Caisse
>         Assigned To: Andy Jefferson
>
> The new test CompletenessTestOrder (use compoundidentity.conf) fails on the RI. It appears
that the OrderItem instances are not persisted to the database.
>     [echo] Starting configuration="compoundidentity.conf" with database="derby"identitytype="applicationidentity"
mapping="".
>     [java] RUN CompletenessTestOrder.test          FAILURE
>     [java] Description: Completeness test with standard mapping using order model for
compound identity testing
>     [java] Time: 009
>     [java] There was 1 failure:
>     [java] 1) test(org.apache.jdo.tck.mapping.CompletenessTestOrder)junit.framework.AssertionFailedError:
CompletenessTestOrder failed; see list of failures below:
>     [java] Expected this  instance:
>     [java]     org.apache.jdo.tck.pc.order.Order@40b181
>     [java] Got persistent instance:
>     [java]     org.apache.jdo.tck.pc.order.Order@1108727
>     [java] Detailed list of differences follows...
>     [java] Context: Order<1>.items
>     [java] expected '[org.apache.jdo.tck.pc.order.OrderItem@2]'
>     [java]   actual '[]'
>     [java]
>     [java]      at org.apache.jdo.tck.JDO_Test.fail(JDO_Test.java:639)
>     [java]      at org.apache.jdo.tck.mapping.CompletenessTestOrder.test(CompletenessTestOrder.java:122)
>     [java]      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     [java]      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>     [java]      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>     [java]      at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java:254)
>     [java]      at org.apache.jdo.tck.util.BatchTestRunner.doRun(BatchTestRunner.java:108)
>     [java]      at org.apache.jdo.tck.util.BatchTestRunner.start(BatchTestRunner.java:148)
>     [java]      at org.apache.jdo.tck.util.BatchTestRunner.main(BatchTestRunner.java:123)

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


Mime
View raw message