[hibernate-commits] Hibernate SVN: r10410 - trunk/Hibernate3/test/org/hibernate/test/optlock

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Fri Sep 1 16:06:16 EDT 2006


Author: steve.ebersole at jboss.com
Date: 2006-09-01 16:06:15 -0400 (Fri, 01 Sep 2006)
New Revision: 10410

Modified:
   trunk/Hibernate3/test/org/hibernate/test/optlock/Document.hbm.xml
   trunk/Hibernate3/test/org/hibernate/test/optlock/OptimisticLockTest.java
Log:
fixed failures on SQLServer

Modified: trunk/Hibernate3/test/org/hibernate/test/optlock/Document.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/optlock/Document.hbm.xml	2006-09-01 20:05:56 UTC (rev 10409)
+++ trunk/Hibernate3/test/org/hibernate/test/optlock/Document.hbm.xml	2006-09-01 20:06:15 UTC (rev 10410)
@@ -14,7 +14,7 @@
 <hibernate-mapping package="org.hibernate.test.optlock">
 	
 	<class name="Document"
-           entity-name="Dirty"
+           entity-name="LockDirty"
            table="Document"
            optimistic-lock="dirty"
            dynamic-update="true">
@@ -33,7 +33,7 @@
 	</class>
 	
 	<class name="Document"
-           entity-name="All"
+           entity-name="LockAll"
            table="Document"
            optimistic-lock="all"
            dynamic-update="true">

Modified: trunk/Hibernate3/test/org/hibernate/test/optlock/OptimisticLockTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/optlock/OptimisticLockTest.java	2006-09-01 20:05:56 UTC (rev 10409)
+++ trunk/Hibernate3/test/org/hibernate/test/optlock/OptimisticLockTest.java	2006-09-01 20:06:15 UTC (rev 10410)
@@ -7,6 +7,8 @@
 import org.hibernate.Session;
 import org.hibernate.StaleObjectStateException;
 import org.hibernate.Transaction;
+import org.hibernate.JDBCException;
+import org.hibernate.dialect.SQLServerDialect;
 import org.hibernate.cfg.Configuration;
 import org.hibernate.cfg.Environment;
 import org.hibernate.test.TestCase;
@@ -37,19 +39,19 @@
 	}
 	
 	public void testOptimisticLockDirty() {
-		testUpdateOptimisticLockFailure( "Dirty" );
+		testUpdateOptimisticLockFailure( "LockDirty" );
 	}
 
 	public void testOptimisticLockAll() {
-		testUpdateOptimisticLockFailure( "All" );
+		testUpdateOptimisticLockFailure( "LockAll" );
 	}
 
 	public void testOptimisticLockDirtyDelete() {
-		testDeleteOptimisticLockFailure( "Dirty" );
+		testDeleteOptimisticLockFailure( "LockDirty" );
 	}
 
 	public void testOptimisticLockAllDelete() {
-		testDeleteOptimisticLockFailure( "All" );
+		testDeleteOptimisticLockFailure( "LockAll" );
 	}
 
 	private void testUpdateOptimisticLockFailure(String entityName) {
@@ -84,6 +86,18 @@
 		catch ( StaleObjectStateException expected ) {
 			// expected result...
 		}
+		catch( JDBCException e ) {
+			// SQLServer will report this condition via a SQLException
+			// when using its SNAPSHOT transaction isolation...
+			if ( ! ( getDialect() instanceof SQLServerDialect && e.getErrorCode() == 3960 ) ) {
+				throw e;
+			}
+			else {
+				// it seems to "lose track" of the transaction as well...
+				t.rollback();
+				t = s.beginTransaction();
+			}
+		}
 		s.clear();
 		t.commit();
 		s.close();
@@ -134,6 +148,18 @@
 		catch ( StaleObjectStateException e ) {
 			// expected
 		}
+		catch( JDBCException e ) {
+			// SQLServer will report this condition via a SQLException
+			// when using its SNAPSHOT transaction isolation...
+			if ( ! ( getDialect() instanceof SQLServerDialect && e.getErrorCode() == 3960 ) ) {
+				throw e;
+			}
+			else {
+				// it seems to "lose track" of the transaction as well...
+				t.rollback();
+				t = s.beginTransaction();
+			}
+		}
 		s.clear();
 		t.commit();
 		s.close();




More information about the hibernate-commits mailing list