cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1210777 - in /cayenne/main/trunk: docs/doc/src/main/resources/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ framework/cayen...
Date Tue, 06 Dec 2011 04:42:25 GMT
Author: aadamchik
Date: Tue Dec  6 04:42:25 2011
New Revision: 1210777

URL: http://svn.apache.org/viewvc?rev=1210777&view=rev
Log:
CAY-1630 [PATCH] On OptimisticLockException, add method to return the object that caused the
failure

providing my own implementation instead of the attached patch

Modified:
    cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/OptimisticLockException.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/BatchAction.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/OptimisticLockingTest.java

Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=1210777&r1=1210776&r2=1210777&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Tue Dec  6 04:42:25 2011
@@ -18,6 +18,7 @@ CAY-1607 [PATCH] add pluralize method to
 CAY-1608 Implement constructor injection support for DefaultAdhocObjectFactory
 CAY-1618 Create database adapters instances with proper injection
 CAY-1629 [PATCH] Can't add custom Hessian serializers to the client
+CAY-1630 [PATCH] On OptimisticLockException, add method to return the object that caused
the failure
 CAY-1637 [PATCH] DataContextFactory is cumbersome to customize
 CAY-1638 [PATCH] Can't disable validation for CayenneContext
 CAY-1639 cayenne-lifecycle: don't call String representation of ObjectId a UUID

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/OptimisticLockException.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/OptimisticLockException.java?rev=1210777&r1=1210776&r2=1210777&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/OptimisticLockException.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/OptimisticLockException.java
Tue Dec  6 04:42:25 2011
@@ -26,6 +26,7 @@ import java.util.Map;
 import org.apache.cayenne.Cayenne;
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.exp.ExpressionFactory;
 import org.apache.cayenne.map.DbAttribute;
@@ -39,14 +40,16 @@ import org.apache.cayenne.query.SelectQu
  */
 public class OptimisticLockException extends CayenneRuntimeException {
 
+    protected ObjectId failedObjectId;
     protected String querySQL;
     protected DbEntity rootEntity;
     protected Map qualifierSnapshot;
 
-    public OptimisticLockException(DbEntity rootEntity, String querySQL,
+    public OptimisticLockException(ObjectId id, DbEntity rootEntity, String querySQL,
             Map qualifierSnapshot) {
         super("Optimistic Lock Failure");
 
+        this.failedObjectId = id;
         this.rootEntity = rootEntity;
         this.querySQL = querySQL;
         this.qualifierSnapshot = (qualifierSnapshot != null)
@@ -114,4 +117,13 @@ public class OptimisticLockException ext
 
         return buffer.toString();
     }
+
+    /**
+     * Returns the object that caused the OptimisticLockException.
+     * 
+     * @since 3.1
+     */
+    public ObjectId getFailedObjectId() {
+        return failedObjectId;
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/BatchAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/BatchAction.java?rev=1210777&r1=1210776&r2=1210777&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/BatchAction.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/BatchAction.java
Tue Dec  6 04:42:25 2011
@@ -216,6 +216,7 @@ public class BatchAction extends BaseSQL
                     }
 
                     throw new OptimisticLockException(
+                            query.getObjectId(),
                             query.getDbEntity(),
                             queryStr,
                             snapshot);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/OptimisticLockingTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/OptimisticLockingTest.java?rev=1210777&r1=1210776&r2=1210777&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/OptimisticLockingTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/OptimisticLockingTest.java
Tue Dec  6 04:42:25 2011
@@ -384,6 +384,7 @@ public class OptimisticLockingTest exten
         }
         catch (OptimisticLockException ex) {
             // optimistic lock failure expected...
+            assertEquals(object.getObjectId(), ex.getFailedObjectId());
         }
     }
 



Mime
View raw message