Skip to content

Commit

Permalink
HHH-7298 org.hibernate.test.dialect.functional.SQLServerDialectTest#t…
Browse files Browse the repository at this point in the history
…estLockNowaitSqlServer catches wrong exception
  • Loading branch information
stliu committed Jun 1, 2012
1 parent c0b4b7a commit 0996a97
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion databases/postgresql84/resources/hibernate.properties
Expand Up @@ -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

Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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 );

Expand Down Expand Up @@ -163,7 +164,7 @@ public void run() {
try {
s2.buildLockRequest( opt ).lock( kit2 );
}
catch ( SQLGrammarException e ) {
catch ( LockTimeoutException e ) {
// OK
}
long end = System.currentTimeMillis();
Expand Down

0 comments on commit 0996a97

Please sign in to comment.