Prefetching may cause a root object to got from COMMITTED to MODIFIED state
---------------------------------------------------------------------------

                 Key: CAY-1277
                 URL: https://issues.apache.org/jira/browse/CAY-1277
             Project: Cayenne
          Issue Type: Bug
          Components: Cayenne Core Library
    Affects Versions: 3.0M6
            Reporter: Andrus Adamchik
            Assignee: Andrus Adamchik
             Fix For: 3.0 beta 1


This is a subtle bug that I am (almost) sure existed prior to my last batch of 
prefetch-related changes. Per test demonstrating it below, prefetching on 
optional to-one relationships would cause a root object to go to MODIFIED state 
instead of COMMITTED. Since this happened without actual values modification, I 
guess nobody noticed it so far. A side effect though (aside from the memory 
leak it might introduce to a read-only DataContext) is that the object never 
refreshes its values from DB.


diff --git 
a/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextPrefetchTest.java
 b/framework/cayenne-jdk1.5-unpublished/sr
index 0c55a60..a5ba2bf 100644
--- 
a/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextPrefetchTest.java
+++ 
b/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextPrefetchTest.java
@@ -464,6 +464,9 @@ public class DataContextPrefetchTest extends 
DataContextCase {
             // testing null to-one target
             Painting p4 = (Painting) results.get(3);
             
assertNull(p4.readPropertyDirectly(Painting.TO_PAINTING_INFO_PROPERTY));
+
+            // there was a bug marking an object as dirty when clearing the 
relationships
+            assertEquals(PersistenceState.COMMITTED, p4.getPersistenceState());
         }
         finally {
             unblockQueries();


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

Reply via email to