Permalink
Browse files

HHH-7298 org.hibernate.test.dialect.functional.SQLServerDialectTest#t…

…estLockNowaitSqlServer catches wrong exception
  • Loading branch information...
1 parent c0b4b7a commit 0996a970ab6515a28c5844f7270ee18a5e1a9114 @stliu stliu committed Jun 1, 2012
@@ -24,7 +24,7 @@
hibernate.dialect org.hibernate.dialect.PostgreSQL82Dialect
hibernate.connection.driver_class org.postgresql.Driver
-hibernate.connection.url jdbc:postgresql://localhost/hibernate
+hibernate.connection.url jdbc:postgresql://127.0.0.1/hibernate
hibernate.connection.username hibernate
hibernate.connection.password hibernate
@@ -34,11 +34,13 @@
import java.sql.SQLException;
import java.util.List;
+import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.LockOptions;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.dialect.SQLServer2005Dialect;
+import org.hibernate.exception.LockTimeoutException;
import org.hibernate.exception.SQLGrammarException;
import org.hibernate.internal.SessionFactoryImpl;
import org.hibernate.jdbc.ReturningWork;
@@ -134,7 +136,6 @@ public void testLockNowaitSqlServer() throws Exception {
Session s2 = openSession();
Transaction tx2 = s2.beginTransaction();
- //s2.createSQLQuery("SET LOCK_TIMEOUT 5000;Select @@LOCK_TIMEOUT;").uniqueResult(); strangely this is useless for this kind of locks
Product2 kit2 = (Product2) s2.byId( Product2.class ).load( kit.id );
@@ -163,7 +164,7 @@ public void run() {
try {
s2.buildLockRequest( opt ).lock( kit2 );
}
- catch ( SQLGrammarException e ) {
+ catch ( LockTimeoutException e ) {
// OK
}
long end = System.currentTimeMillis();

0 comments on commit 0996a97

Please sign in to comment.