db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject svn commit: r508950 - in /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle: StateTransitions.java StateTransitionsReturnedObjects.java
Date Sun, 18 Feb 2007 19:30:23 GMT
Author: clr
Date: Sun Feb 18 11:30:22 2007
New Revision: 508950

URL: http://svn.apache.org/viewvc?view=rev&rev=508950
Log:
JDO-460 made getHollowInstance and getPersistentNontransactionalInstance reliably get instances
in these states

Modified:
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/StateTransitions.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/StateTransitionsReturnedObjects.java

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/StateTransitions.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/StateTransitions.java?view=diff&rev=508950&r1=508949&r2=508950
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/StateTransitions.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/StateTransitions.java Sun Feb
18 11:30:22 2007
@@ -912,6 +912,7 @@
         }
         StateTransitionObj obj = (StateTransitionObj) iter.next();
         
+        pm.makeTransactional(obj);
         transaction.setRetainValues(false);
         transaction.commit(); // This should put the instance in the HOLLOW state
 
@@ -920,7 +921,7 @@
         int curr = currentState(obj);
         if( curr != HOLLOW && curr != PERSISTENT_NONTRANSACTIONAL ){
             if (debug) {
-                logger.debug("StateTransition: Attempt to get hollow instance via accessing
extent failed, state is " +
+                logger.debug("getHollowInstance: Attempt to get hollow instance via accessing
extent failed, state is " +
                              states[curr]);
             }
             return null;
@@ -1006,7 +1007,12 @@
     {
         StateTransitionObj obj = getHollowInstance();
         if( obj == null ) return null;
+        boolean nontransactionalRead = 
+                pm.currentTransaction().getNontransactionalRead();
+        pm.currentTransaction().setNontransactionalRead(true);
+        obj.readField();
         pm.makeNontransactional(obj);
+        pm.currentTransaction().setNontransactionalRead(nontransactionalRead);
         int curr = currentState(obj);
         if( curr != PERSISTENT_NONTRANSACTIONAL && curr != HOLLOW ) { 
             if (debug) {

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/StateTransitionsReturnedObjects.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/StateTransitionsReturnedObjects.java?view=diff&rev=508950&r1=508949&r2=508950
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/StateTransitionsReturnedObjects.java
(original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/StateTransitionsReturnedObjects.java
Sun Feb 18 11:30:22 2007
@@ -544,6 +544,12 @@
     /** */
     public StateTransitionObj getHollowInstance()
     {
+        if ( !transaction.isActive() )
+            transaction.begin();
+        if( !transaction.isActive() )
+            if (debug)
+                logger.debug("getHollowInstance: Transaction should be active, but it is
not");
+        
         Extent extent = pm.getExtent(StateTransitionObj.class, false);
         Iterator iter = extent.iterator();
         if( !iter.hasNext() ){
@@ -553,13 +559,8 @@
         }
         StateTransitionObj obj = (StateTransitionObj) iter.next();
         
+        pm.makeTransactional(obj);
         transaction.setRetainValues(false);
-        if ( !transaction.isActive() )
-            transaction.begin();
-        if( !transaction.isActive() )
-            if (debug)
-                logger.debug("getHollowInstance: Transaction should be active, but it is
not");
-        
         transaction.commit(); // This should put the instance in the HOLLOW state
 
         prepareTransactionAndJDOSettings(transaction);
@@ -567,7 +568,7 @@
         int curr = currentState(obj);
         if( curr != HOLLOW && curr != PERSISTENT_NONTRANSACTIONAL ){
             if (debug) {
-                logger.debug("StateTransitionsReturnedObjects: Attempt to get hollow instance
via accessing extent failed, state is " +
+                logger.debug("getHollowInstance: Attempt to get hollow instance via accessing
extent failed, state is " +
                              states[curr]);
             }
             return null;
@@ -653,7 +654,12 @@
     {
         StateTransitionObj obj = getHollowInstance();
         if( obj == null ) return null;
+        boolean nontransactionalRead = 
+                pm.currentTransaction().getNontransactionalRead();
+        pm.currentTransaction().setNontransactionalRead(true);
+        obj.readField();
         pm.makeNontransactional(obj);
+        pm.currentTransaction().setNontransactionalRead(nontransactionalRead);
         int curr = currentState(obj);
         if( curr != PERSISTENT_NONTRANSACTIONAL && curr != HOLLOW ) { 
             if (debug) {



Mime
View raw message