You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-dev@db.apache.org by "Andy Jefferson (JIRA)" <ji...@apache.org> on 2010/11/19 20:06:15 UTC

[jira] Created: (JDO-669) TCK : RelationshipManyToManyAllRelationships.testDeleteFromMappedSide - problem with check

TCK : RelationshipManyToManyAllRelationships.testDeleteFromMappedSide - problem with check
------------------------------------------------------------------------------------------

                 Key: JDO-669
                 URL: https://issues.apache.org/jira/browse/JDO-669
             Project: JDO
          Issue Type: Bug
          Components: specification, tck
    Affects Versions: JDO 3
            Reporter: Andy Jefferson
             Fix For: JDO 3 maintenance release 1


Whilst this test passes with current DataNucleus (2.2 M3), I was in the process of extending its support for managed relationships, and now get this test to fail which provokes this question :-

pm.deletePersistent(proj1);
pm.flush();
deferredAssertTrue(!emp1.getProjects().contains(proj1),
    ASSERTION_FAILED + testMethod, "Postcondition is false; other side of relationship not set on flush");

After the call to deletePersistent() and flush() the object "proj1" is in P_DELETED state. So when the call goes in to emp1.getProjects().contains(proj) this will interrogate the hashCode() method of Project. This is defined as

public int hashCode() {
    return (int)projid;
}

But when using datastore identity "projid" is not a primary-key field, and so, as per section 5.5.6 of the spec 
<spec>Read access to primary key fields is permitted. Any other access to persistent fields is not supported and might throw a JDOUserException.</spec>
So what does the implementation do ?

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


[jira] Commented: (JDO-669) TCK : RelationshipManyToManyAllRelationships.testDeleteFromMappedSide - problem with check

Posted by "Craig L Russell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JDO-669?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12934906#action_12934906 ] 

Craig L Russell commented on JDO-669:
-------------------------------------

So instead of a failure you would get an error in the failing case.

It's not obvious to me that it's worth reworking this to change an error to a failure...

> TCK : RelationshipManyToManyAllRelationships.testDeleteFromMappedSide - problem with check
> ------------------------------------------------------------------------------------------
>
>                 Key: JDO-669
>                 URL: https://issues.apache.org/jira/browse/JDO-669
>             Project: JDO
>          Issue Type: Bug
>          Components: tck
>    Affects Versions: JDO 3
>            Reporter: Andy Jefferson
>            Assignee: Craig L Russell
>             Fix For: JDO 3 maintenance release 1
>
>         Attachments: jdo-669.patch
>
>
> Whilst this test passes with current DataNucleus (2.2 M3), I was in the process of extending its support for managed relationships, and now get this test to fail which provokes this question :-
> pm.deletePersistent(proj1);
> pm.flush();
> deferredAssertTrue(!emp1.getProjects().contains(proj1),
>     ASSERTION_FAILED + testMethod, "Postcondition is false; other side of relationship not set on flush");
> After the call to deletePersistent() and flush() the object "proj1" is in P_DELETED state. So when the call goes in to emp1.getProjects().contains(proj) this will interrogate the hashCode() method of Project. This is defined as
> public int hashCode() {
>     return (int)projid;
> }
> But when using datastore identity "projid" is not a primary-key field, and so, as per section 5.5.6 of the spec 
> <spec>Read access to primary key fields is permitted. Any other access to persistent fields is not supported and might throw a JDOUserException.</spec>
> So what does the implementation do ?

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


[jira] Commented: (JDO-669) TCK : RelationshipManyToManyAllRelationships.testDeleteFromMappedSide - problem with check

Posted by "Andy Jefferson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JDO-669?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12935672#action_12935672 ] 

Andy Jefferson commented on JDO-669:
------------------------------------

DN passes with the new code regardless of which way it is, so why not just check in

> TCK : RelationshipManyToManyAllRelationships.testDeleteFromMappedSide - problem with check
> ------------------------------------------------------------------------------------------
>
>                 Key: JDO-669
>                 URL: https://issues.apache.org/jira/browse/JDO-669
>             Project: JDO
>          Issue Type: Bug
>          Components: tck
>    Affects Versions: JDO 3
>            Reporter: Andy Jefferson
>            Assignee: Craig L Russell
>             Fix For: JDO 3 maintenance release 1
>
>         Attachments: jdo-669.patch
>
>
> Whilst this test passes with current DataNucleus (2.2 M3), I was in the process of extending its support for managed relationships, and now get this test to fail which provokes this question :-
> pm.deletePersistent(proj1);
> pm.flush();
> deferredAssertTrue(!emp1.getProjects().contains(proj1),
>     ASSERTION_FAILED + testMethod, "Postcondition is false; other side of relationship not set on flush");
> After the call to deletePersistent() and flush() the object "proj1" is in P_DELETED state. So when the call goes in to emp1.getProjects().contains(proj) this will interrogate the hashCode() method of Project. This is defined as
> public int hashCode() {
>     return (int)projid;
> }
> But when using datastore identity "projid" is not a primary-key field, and so, as per section 5.5.6 of the spec 
> <spec>Read access to primary key fields is permitted. Any other access to persistent fields is not supported and might throw a JDOUserException.</spec>
> So what does the implementation do ?

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


[jira] Commented: (JDO-669) TCK : RelationshipManyToManyAllRelationships.testDeleteFromMappedSide - problem with check

Posted by "Craig L Russell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JDO-669?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12933958#action_12933958 ] 

Craig L Russell commented on JDO-669:
-------------------------------------

It's a test case bug. It's not permitted to access a persistent field after the object has been deleted.

The test case should be changed to perform a different check to see if the deleted instance is in the collection. This can be done by saving the id before deleting the instance and later checking to see if any of the instances in the collection have that id.


> TCK : RelationshipManyToManyAllRelationships.testDeleteFromMappedSide - problem with check
> ------------------------------------------------------------------------------------------
>
>                 Key: JDO-669
>                 URL: https://issues.apache.org/jira/browse/JDO-669
>             Project: JDO
>          Issue Type: Bug
>          Components: tck
>    Affects Versions: JDO 3
>            Reporter: Andy Jefferson
>            Assignee: Craig L Russell
>             Fix For: JDO 3 maintenance release 1
>
>
> Whilst this test passes with current DataNucleus (2.2 M3), I was in the process of extending its support for managed relationships, and now get this test to fail which provokes this question :-
> pm.deletePersistent(proj1);
> pm.flush();
> deferredAssertTrue(!emp1.getProjects().contains(proj1),
>     ASSERTION_FAILED + testMethod, "Postcondition is false; other side of relationship not set on flush");
> After the call to deletePersistent() and flush() the object "proj1" is in P_DELETED state. So when the call goes in to emp1.getProjects().contains(proj) this will interrogate the hashCode() method of Project. This is defined as
> public int hashCode() {
>     return (int)projid;
> }
> But when using datastore identity "projid" is not a primary-key field, and so, as per section 5.5.6 of the spec 
> <spec>Read access to primary key fields is permitted. Any other access to persistent fields is not supported and might throw a JDOUserException.</spec>
> So what does the implementation do ?

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


[jira] Resolved: (JDO-669) TCK : RelationshipManyToManyAllRelationships.testDeleteFromMappedSide - problem with check

Posted by "Craig L Russell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JDO-669?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Craig L Russell resolved JDO-669.
---------------------------------

    Resolution: Fixed

svn commit -m "JDO-669 Avoid using hashCode and equals in contains test for deleted objects" src/java/org/apache/jdo/tck/
Sending        src/java/org/apache/jdo/tck/mapping/AbstractRelationshipTest.java
Sending        src/java/org/apache/jdo/tck/mapping/Relationship1ToManyAllRelationships.java
Sending        src/java/org/apache/jdo/tck/mapping/RelationshipManyToManyAllRelationships.java
Transmitting file data ...
Committed revision 1039618.


> TCK : RelationshipManyToManyAllRelationships.testDeleteFromMappedSide - problem with check
> ------------------------------------------------------------------------------------------
>
>                 Key: JDO-669
>                 URL: https://issues.apache.org/jira/browse/JDO-669
>             Project: JDO
>          Issue Type: Bug
>          Components: tck
>    Affects Versions: JDO 3
>            Reporter: Andy Jefferson
>            Assignee: Craig L Russell
>             Fix For: JDO 3 maintenance release 1
>
>         Attachments: jdo-669.patch
>
>
> Whilst this test passes with current DataNucleus (2.2 M3), I was in the process of extending its support for managed relationships, and now get this test to fail which provokes this question :-
> pm.deletePersistent(proj1);
> pm.flush();
> deferredAssertTrue(!emp1.getProjects().contains(proj1),
>     ASSERTION_FAILED + testMethod, "Postcondition is false; other side of relationship not set on flush");
> After the call to deletePersistent() and flush() the object "proj1" is in P_DELETED state. So when the call goes in to emp1.getProjects().contains(proj) this will interrogate the hashCode() method of Project. This is defined as
> public int hashCode() {
>     return (int)projid;
> }
> But when using datastore identity "projid" is not a primary-key field, and so, as per section 5.5.6 of the spec 
> <spec>Read access to primary key fields is permitted. Any other access to persistent fields is not supported and might throw a JDOUserException.</spec>
> So what does the implementation do ?

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


[jira] Commented: (JDO-669) TCK : RelationshipManyToManyAllRelationships.testDeleteFromMappedSide - problem with check

Posted by "Andy Jefferson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JDO-669?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12934794#action_12934794 ] 

Andy Jefferson commented on JDO-669:
------------------------------------

Patch : better but still not complete.
containsProject, containsEmployee still call xxx.getField() and one of those objects in the collection could be the deleted one. 

an example stack trace (using DN SVN)
    [java] 2) testDeleteFromMappedbySide(org.apache.jdo.tck.mapping.RelationshipManyToManyAllRelationships)javax.jdo.JDOUserException: Cannot read fields from a deleted object
    [java] FailedObject:1882[OID]org.apache.jdo.tck.pc.company.FullTimeEmployee
    [java]      at org.datanucleus.jdo.state.PersistentDeleted.transitionReadField(PersistentDeleted.java:116)
    [java]      at org.datanucleus.state.AbstractStateManager.transitionReadField(AbstractStateManager.java:551)
    [java]      at org.datanucleus.jdo.state.JDOStateManagerImpl.isLoaded(JDOStateManagerImpl.java:2078)
    [java]      at org.apache.jdo.tck.pc.company.Person.jdoGetpersonid(Person.java)
    [java]      at org.apache.jdo.tck.pc.company.Person.getPersonid(Person.java:104)
    [java]      at org.apache.jdo.tck.mapping.AbstractRelationshipTest.containsEmployee(AbstractRelationshipTest.java:80)
    [java]      at org.apache.jdo.tck.mapping.RelationshipManyToManyAllRelationships.testDeleteFromMappedbySide(RelationshipManyToManyAllRelationships.java:480)
    [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:272)

I think you need collections of the object ids only (before any objects are deleted), and use these in the comparison

> TCK : RelationshipManyToManyAllRelationships.testDeleteFromMappedSide - problem with check
> ------------------------------------------------------------------------------------------
>
>                 Key: JDO-669
>                 URL: https://issues.apache.org/jira/browse/JDO-669
>             Project: JDO
>          Issue Type: Bug
>          Components: tck
>    Affects Versions: JDO 3
>            Reporter: Andy Jefferson
>            Assignee: Craig L Russell
>             Fix For: JDO 3 maintenance release 1
>
>         Attachments: jdo-669.patch
>
>
> Whilst this test passes with current DataNucleus (2.2 M3), I was in the process of extending its support for managed relationships, and now get this test to fail which provokes this question :-
> pm.deletePersistent(proj1);
> pm.flush();
> deferredAssertTrue(!emp1.getProjects().contains(proj1),
>     ASSERTION_FAILED + testMethod, "Postcondition is false; other side of relationship not set on flush");
> After the call to deletePersistent() and flush() the object "proj1" is in P_DELETED state. So when the call goes in to emp1.getProjects().contains(proj) this will interrogate the hashCode() method of Project. This is defined as
> public int hashCode() {
>     return (int)projid;
> }
> But when using datastore identity "projid" is not a primary-key field, and so, as per section 5.5.6 of the spec 
> <spec>Read access to primary key fields is permitted. Any other access to persistent fields is not supported and might throw a JDOUserException.</spec>
> So what does the implementation do ?

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


[jira] Assigned: (JDO-669) TCK : RelationshipManyToManyAllRelationships.testDeleteFromMappedSide - problem with check

Posted by "Craig L Russell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JDO-669?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Craig L Russell reassigned JDO-669:
-----------------------------------

    Assignee: Craig L Russell

> TCK : RelationshipManyToManyAllRelationships.testDeleteFromMappedSide - problem with check
> ------------------------------------------------------------------------------------------
>
>                 Key: JDO-669
>                 URL: https://issues.apache.org/jira/browse/JDO-669
>             Project: JDO
>          Issue Type: Bug
>          Components: specification, tck
>    Affects Versions: JDO 3
>            Reporter: Andy Jefferson
>            Assignee: Craig L Russell
>             Fix For: JDO 3 maintenance release 1
>
>
> Whilst this test passes with current DataNucleus (2.2 M3), I was in the process of extending its support for managed relationships, and now get this test to fail which provokes this question :-
> pm.deletePersistent(proj1);
> pm.flush();
> deferredAssertTrue(!emp1.getProjects().contains(proj1),
>     ASSERTION_FAILED + testMethod, "Postcondition is false; other side of relationship not set on flush");
> After the call to deletePersistent() and flush() the object "proj1" is in P_DELETED state. So when the call goes in to emp1.getProjects().contains(proj) this will interrogate the hashCode() method of Project. This is defined as
> public int hashCode() {
>     return (int)projid;
> }
> But when using datastore identity "projid" is not a primary-key field, and so, as per section 5.5.6 of the spec 
> <spec>Read access to primary key fields is permitted. Any other access to persistent fields is not supported and might throw a JDOUserException.</spec>
> So what does the implementation do ?

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


[jira] Updated: (JDO-669) TCK : RelationshipManyToManyAllRelationships.testDeleteFromMappedSide - problem with check

Posted by "Craig L Russell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JDO-669?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Craig L Russell updated JDO-669:
--------------------------------

    Attachment: jdo-669.patch

Please review this patch. It removes the ill-fated contains(deletedObject) and replaces it with a safe test.

There might be other tests that have a similar check but I didn't find any.

> TCK : RelationshipManyToManyAllRelationships.testDeleteFromMappedSide - problem with check
> ------------------------------------------------------------------------------------------
>
>                 Key: JDO-669
>                 URL: https://issues.apache.org/jira/browse/JDO-669
>             Project: JDO
>          Issue Type: Bug
>          Components: tck
>    Affects Versions: JDO 3
>            Reporter: Andy Jefferson
>            Assignee: Craig L Russell
>             Fix For: JDO 3 maintenance release 1
>
>         Attachments: jdo-669.patch
>
>
> Whilst this test passes with current DataNucleus (2.2 M3), I was in the process of extending its support for managed relationships, and now get this test to fail which provokes this question :-
> pm.deletePersistent(proj1);
> pm.flush();
> deferredAssertTrue(!emp1.getProjects().contains(proj1),
>     ASSERTION_FAILED + testMethod, "Postcondition is false; other side of relationship not set on flush");
> After the call to deletePersistent() and flush() the object "proj1" is in P_DELETED state. So when the call goes in to emp1.getProjects().contains(proj) this will interrogate the hashCode() method of Project. This is defined as
> public int hashCode() {
>     return (int)projid;
> }
> But when using datastore identity "projid" is not a primary-key field, and so, as per section 5.5.6 of the spec 
> <spec>Read access to primary key fields is permitted. Any other access to persistent fields is not supported and might throw a JDOUserException.</spec>
> So what does the implementation do ?

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


[jira] Updated: (JDO-669) TCK : RelationshipManyToManyAllRelationships.testDeleteFromMappedSide - problem with check

Posted by "Craig L Russell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JDO-669?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Craig L Russell updated JDO-669:
--------------------------------

    Component/s:     (was: specification)

The specification does not need to be changed.

> TCK : RelationshipManyToManyAllRelationships.testDeleteFromMappedSide - problem with check
> ------------------------------------------------------------------------------------------
>
>                 Key: JDO-669
>                 URL: https://issues.apache.org/jira/browse/JDO-669
>             Project: JDO
>          Issue Type: Bug
>          Components: tck
>    Affects Versions: JDO 3
>            Reporter: Andy Jefferson
>            Assignee: Craig L Russell
>             Fix For: JDO 3 maintenance release 1
>
>
> Whilst this test passes with current DataNucleus (2.2 M3), I was in the process of extending its support for managed relationships, and now get this test to fail which provokes this question :-
> pm.deletePersistent(proj1);
> pm.flush();
> deferredAssertTrue(!emp1.getProjects().contains(proj1),
>     ASSERTION_FAILED + testMethod, "Postcondition is false; other side of relationship not set on flush");
> After the call to deletePersistent() and flush() the object "proj1" is in P_DELETED state. So when the call goes in to emp1.getProjects().contains(proj) this will interrogate the hashCode() method of Project. This is defined as
> public int hashCode() {
>     return (int)projid;
> }
> But when using datastore identity "projid" is not a primary-key field, and so, as per section 5.5.6 of the spec 
> <spec>Read access to primary key fields is permitted. Any other access to persistent fields is not supported and might throw a JDOUserException.</spec>
> So what does the implementation do ?

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