You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2013/02/21 22:45:11 UTC
svn commit: r1448816 - in /db/torque/torque4/trunk:
torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/
torque-test/src/test/java/org/apache/torque/generated/peer/
Author: tfischer
Date: Thu Feb 21 21:45:10 2013
New Revision: 1448816
URL: http://svn.apache.org/r1448816
Log:
TORQUE-267 improve exception messages; use NoRowsException if no row can be found to be updated
Modified:
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doUpdate.vm
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/BaseOptimisticLockingTest.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/OptimisticLockingSelectForUpdateTest.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/OptimisticLockingSimpleSelectTest.java
Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doUpdate.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doUpdate.vm?rev=1448816&r1=1448815&r2=1448816&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doUpdate.vm (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doUpdate.vm Thu Feb 21 21:45:10 2013
@@ -108,15 +108,17 @@
#set ( $columnGetter = $columnElement.getAttribute("getter"))
if ($field == null)
{
- throw new OptimisticLockingFailedException(
- "The row was deleted concurrently");
+ throw new NoRowsException(
+ "The row to update does not exist in the database");
}
if (!ObjectUtils.equals(
${field}.${columnGetter}(),
$columnField))
{
throw new OptimisticLockingFailedException(
- "The row was updated concurrently");
+ "The row was updated concurrently. Version in database: "
+ + ${field}.${columnGetter}() + ", version in memory: "
+ + $columnField);
}
#end
#end
@@ -141,7 +143,7 @@
if (rowCount == 0)
{
throw new OptimisticLockingFailedException(
- "The row was either updated or deleted concurrently "
+ "The row to update was either updated or deleted concurrently "
+ "or does not exist at all.");
}
#end
Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/BaseOptimisticLockingTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/BaseOptimisticLockingTest.java?rev=1448816&r1=1448815&r2=1448816&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/BaseOptimisticLockingTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/BaseOptimisticLockingTest.java Thu Feb 21 21:45:10 2013
@@ -206,7 +206,7 @@ public abstract class BaseOptimisticLock
}
catch (OptimisticLockingFailedException e)
{
- // expected
+ assertOptimisticLockingUpdateException(e);
}
// verify
@@ -238,11 +238,11 @@ public abstract class BaseOptimisticLock
try
{
toUpdate.save();
- fail("Exception excpected");
+ fail("Exception expected");
}
- catch (OptimisticLockingFailedException e)
+ catch (TorqueException e)
{
- // expected
+ assertOptimisticLockingDeleteException(e);
}
// verify
@@ -286,4 +286,10 @@ public abstract class BaseOptimisticLock
}
public abstract T newObject();
+
+ public abstract void assertOptimisticLockingUpdateException(
+ TorqueException e);
+
+ public abstract void assertOptimisticLockingDeleteException(
+ TorqueException e);
}
Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/OptimisticLockingSelectForUpdateTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/OptimisticLockingSelectForUpdateTest.java?rev=1448816&r1=1448815&r2=1448816&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/OptimisticLockingSelectForUpdateTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/OptimisticLockingSelectForUpdateTest.java Thu Feb 21 21:45:10 2013
@@ -19,6 +19,9 @@ package org.apache.torque.generated.peer
* under the License.
*/
+import org.apache.torque.NoRowsException;
+import org.apache.torque.OptimisticLockingFailedException;
+import org.apache.torque.TorqueException;
import org.apache.torque.test.dbobject.OptimisticLocking;
import org.apache.torque.test.peer.OptimisticLockingPeerImpl;
@@ -27,7 +30,8 @@ import org.apache.torque.test.peer.Optim
*
* @version $Id$
*/
-public class OptimisticLockingSelectForUpdateTest extends BaseOptimisticLockingTest<OptimisticLocking>
+public class OptimisticLockingSelectForUpdateTest
+ extends BaseOptimisticLockingTest<OptimisticLocking>
{
public OptimisticLockingSelectForUpdateTest()
{
@@ -38,4 +42,21 @@ public class OptimisticLockingSelectForU
{
return new OptimisticLocking();
}
+
+ @Override
+ public void assertOptimisticLockingDeleteException(TorqueException e) {
+ assertTrue(e instanceof NoRowsException);
+ assertEquals(
+ "The row to update does not exist in the database",
+ e.getMessage());
+ }
+
+ @Override
+ public void assertOptimisticLockingUpdateException(TorqueException e) {
+ assertTrue(e instanceof OptimisticLockingFailedException);
+ assertEquals(
+ "The row was updated concurrently. Version in database: 1"
+ + ", version in memory: 0",
+ e.getMessage());
+ }
}
Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/OptimisticLockingSimpleSelectTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/OptimisticLockingSimpleSelectTest.java?rev=1448816&r1=1448815&r2=1448816&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/OptimisticLockingSimpleSelectTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/OptimisticLockingSimpleSelectTest.java Thu Feb 21 21:45:10 2013
@@ -19,6 +19,8 @@ package org.apache.torque.generated.peer
* under the License.
*/
+import org.apache.torque.OptimisticLockingFailedException;
+import org.apache.torque.TorqueException;
import org.apache.torque.test.dbobject.OptimisticLockingSimple;
import org.apache.torque.test.peer.OptimisticLockingSimplePeerImpl;
@@ -38,4 +40,22 @@ public class OptimisticLockingSimpleSele
{
return new OptimisticLockingSimple();
}
+
+ @Override
+ public void assertOptimisticLockingDeleteException(TorqueException e) {
+ assertTrue(e instanceof OptimisticLockingFailedException);
+ assertEquals(
+ "The row to update was either updated or deleted concurrently "
+ + "or does not exist at all.",
+ e.getMessage());
+ }
+
+ @Override
+ public void assertOptimisticLockingUpdateException(TorqueException e) {
+ assertTrue(e instanceof OptimisticLockingFailedException);
+ assertEquals(
+ "The row to update was either updated or deleted concurrently "
+ + "or does not exist at all.",
+ e.getMessage());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org