diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java index bfecbc082c..22eae36a52 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java @@ -55,6 +55,7 @@ public class SQLServerDialect extends AbstractTransactSQLDialect { registerFunction( "trim", new AnsiTrimEmulationFunction() ); registerKeyword( "top" ); + registerKeyword( "key" ); this.limitHandler = new TopLimitHandler( false, false ); } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/internal/NormalizingIdentifierHelperImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/internal/NormalizingIdentifierHelperImpl.java index 144b4f4ad6..4e3d1808e3 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/internal/NormalizingIdentifierHelperImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/internal/NormalizingIdentifierHelperImpl.java @@ -74,7 +74,7 @@ public class NormalizingIdentifierHelperImpl implements IdentifierHelper { } if ( autoQuoteKeywords && isReservedWord( identifier.getText() ) ) { - log.tracef( "Forcing identifier [%s] to quoted as recognized reserveed word", identifier ); + log.tracef( "Forcing identifier [%s] to quoted as recognized reserved word", identifier ); return Identifier.toIdentifier( identifier.getText(), true ); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/dialect/functional/Product2.java b/hibernate-core/src/test/java/org/hibernate/test/dialect/functional/Product2.java index 137af50030..a3560829dd 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/dialect/functional/Product2.java +++ b/hibernate-core/src/test/java/org/hibernate/test/dialect/functional/Product2.java @@ -13,7 +13,6 @@ import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.ManyToOne; -import javax.persistence.Table; /** * @author Guenther Demetz diff --git a/hibernate-core/src/test/java/org/hibernate/test/dialect/functional/SQLServerDialectTest.java b/hibernate-core/src/test/java/org/hibernate/test/dialect/functional/SQLServerDialectTest.java index 1f8c9684a6..5ea50c82a4 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/dialect/functional/SQLServerDialectTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/dialect/functional/SQLServerDialectTest.java @@ -6,32 +6,43 @@ */ package org.hibernate.test.dialect.functional; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Arrays; +import java.util.Collections; import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import javax.persistence.Entity; +import javax.persistence.Id; import org.hibernate.LockMode; import org.hibernate.LockOptions; import org.hibernate.Session; import org.hibernate.Transaction; +import org.hibernate.cfg.AvailableSettings; +import org.hibernate.cfg.Configuration; import org.hibernate.criterion.Order; import org.hibernate.criterion.Projections; import org.hibernate.dialect.SQLServer2005Dialect; import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.exception.LockTimeoutException; import org.hibernate.jdbc.ReturningWork; + import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; +import org.junit.Ignore; import org.junit.Test; +import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + /** * used driver hibernate.connection.driver_class com.microsoft.sqlserver.jdbc.SQLServerDriver * @@ -39,41 +50,48 @@ import org.junit.Test; */ @RequiresDialect(value = { SQLServer2005Dialect.class }) public class SQLServerDialectTest extends BaseCoreFunctionalTestCase { + + private final ExecutorService executorService = Executors.newSingleThreadExecutor(); + + @Override + protected Configuration constructConfiguration() { + Configuration configuration = super.constructConfiguration(); + configuration.setProperty( AvailableSettings.KEYWORD_AUTO_QUOTING_ENABLED, Boolean.TRUE.toString() ); + return configuration; + } + @Test @TestForIssue(jiraKey = "HHH-7198") public void testMaxResultsSqlServerWithCaseSensitiveCollation() throws Exception { - final Session s = openSession(); - s.beginTransaction(); - String defaultCollationName = s.doReturningWork( new ReturningWork() { - @Override - public String execute(Connection connection) throws SQLException { - String databaseName = connection.getCatalog(); - Statement st = ((SessionImplementor)s).getJdbcCoordinator().getStatementPreparer().createStatement(); - ResultSet rs = ((SessionImplementor)s).getJdbcCoordinator().getResultSetReturn().extract( st, "SELECT collation_name FROM sys.databases WHERE name = '"+databaseName+ "';" ); - while(rs.next()){ - return rs.getString( "collation_name" ); - } - throw new AssertionError( "can't get collation name of database "+databaseName ); - + final Session s1 = openSession(); + s1.beginTransaction(); + String defaultCollationName = s1.doReturningWork( connection -> { + String databaseName = connection.getCatalog(); + Statement st = ((SessionImplementor)s1).getJdbcCoordinator().getStatementPreparer().createStatement(); + ResultSet rs = ((SessionImplementor)s1).getJdbcCoordinator().getResultSetReturn().extract( st, "SELECT collation_name FROM sys.databases WHERE name = '"+databaseName+ "';" ); + while(rs.next()){ + return rs.getString( "collation_name" ); } + throw new AssertionError( "can't get collation name of database "+databaseName ); + } ); - s.getTransaction().commit(); - s.close(); + s1.getTransaction().commit(); + s1.close(); Session s2 = openSession(); + Transaction tx = s2.beginTransaction(); + String databaseName = s2.doReturningWork( new ReturningWork() { @Override public String execute(Connection connection) throws SQLException { return connection.getCatalog(); } } ); - s2.createSQLQuery( "ALTER DATABASE " + databaseName + " set single_user with rollback immediate" ) + s2.createNativeQuery( "ALTER DATABASE " + databaseName + " set single_user with rollback immediate" ) .executeUpdate(); - s2.createSQLQuery( "ALTER DATABASE " + databaseName + " COLLATE Latin1_General_CS_AS" ).executeUpdate(); - s2.createSQLQuery( "ALTER DATABASE " + databaseName + " set multi_user" ).executeUpdate(); - - Transaction tx = s2.beginTransaction(); + s2.createNativeQuery( "ALTER DATABASE " + databaseName + " COLLATE Latin1_General_CS_AS" ).executeUpdate(); + s2.createNativeQuery( "ALTER DATABASE " + databaseName + " set multi_user" ).executeUpdate(); for ( int i = 1; i <= 20; i++ ) { s2.persist( new Product2( i, "Kit" + i ) ); @@ -89,213 +107,183 @@ public class SQLServerDialectTest extends BaseCoreFunctionalTestCase { tx.rollback(); s2.close(); - s2 = openSession(); - s2.createSQLQuery( "ALTER DATABASE " + databaseName + " set single_user with rollback immediate" ) - .executeUpdate(); - s2.createSQLQuery( "ALTER DATABASE " + databaseName + " COLLATE " + defaultCollationName ).executeUpdate(); - s2.createSQLQuery( "ALTER DATABASE " + databaseName + " set multi_user" ).executeUpdate(); - s2.close(); - } - - private void doWork(Session s) { - + executorService.execute( () -> { + doInHibernate( this::sessionFactory, s3 -> { + s3.createNativeQuery( "ALTER DATABASE " + databaseName + " set single_user with rollback immediate" ) + .executeUpdate(); + s3.createNativeQuery( "ALTER DATABASE " + databaseName + " COLLATE " + defaultCollationName ).executeUpdate(); + s3.createNativeQuery( "ALTER DATABASE " + databaseName + " set multi_user" ).executeUpdate(); + } ); + } ); } @Test @TestForIssue(jiraKey = "HHH-7369") public void testPaginationWithScalarQuery() throws Exception { - Session s = openSession(); - Transaction tx = s.beginTransaction(); + doInHibernate( this::sessionFactory, session -> { + for ( int i = 0; i < 10; i++ ) { + session.persist( new Product2( i, "Kit" + i ) ); + } + session.flush(); + session.clear(); - for ( int i = 0; i < 10; i++ ) { - s.persist( new Product2( i, "Kit" + i ) ); - } - s.flush(); - s.clear(); + List list = session.createNativeQuery( "select id from Product2 where description like 'Kit%' order by id" ).list(); + assertEquals(Integer.class, list.get(0).getClass()); // scalar result is an Integer - List list = s.createSQLQuery( "select id from Product2 where description like 'Kit%' order by id" ).list(); - assertEquals(Integer.class, list.get(0).getClass()); // scalar result is an Integer + list = session.createNativeQuery( "select id from Product2 where description like 'Kit%' order by id" ).setFirstResult( 2 ).setMaxResults( 2 ).list(); + assertEquals(Integer.class, list.get(0).getClass()); // this fails without patch, as result suddenly has become an array - list = s.createSQLQuery( "select id from Product2 where description like 'Kit%' order by id" ).setFirstResult( 2 ).setMaxResults( 2 ).list(); - assertEquals(Integer.class, list.get(0).getClass()); // this fails without patch, as result suddenly has become an array - - // same once again with alias - list = s.createSQLQuery( "select id as myint from Product2 where description like 'Kit%' order by id asc" ).setFirstResult( 2 ).setMaxResults( 2 ).list(); - assertEquals(Integer.class, list.get(0).getClass()); - - tx.rollback(); - s.close(); + // same once again with alias + list = session.createNativeQuery( "select id as myint from Product2 where description like 'Kit%' order by id asc" ).setFirstResult( 2 ).setMaxResults( 2 ).list(); + assertEquals(Integer.class, list.get(0).getClass()); + } ); } @Test @TestForIssue(jiraKey = "HHH-7368") public void testPaginationWithTrailingSemicolon() throws Exception { - Session s = openSession(); - s.createSQLQuery( "select id from Product2 where description like 'Kit%' order by id;" ) - .setFirstResult( 2 ).setMaxResults( 2 ).list(); - s.close(); + doInHibernate( this::sessionFactory, session -> { + session.createNativeQuery( "select id from Product2 where description like 'Kit%' order by id;" ) + .setFirstResult( 2 ).setMaxResults( 2 ).list(); + } ); } @Test public void testPaginationWithHQLProjection() { - Session session = openSession(); - Transaction tx = session.beginTransaction(); + doInHibernate( this::sessionFactory, session -> { + for ( int i = 10; i < 20; i++ ) { + session.persist( new Product2( i, "Kit" + i ) ); + } + session.flush(); + session.clear(); - for ( int i = 10; i < 20; i++ ) { - session.persist( new Product2( i, "Kit" + i ) ); - } - session.flush(); - session.clear(); + List list = session.createQuery( + "select id, description as descr, (select max(id) from Product2) as maximum from Product2" + ).setFirstResult( 2 ).setMaxResults( 2 ).list(); + assertEquals( 19, ( (Object[]) list.get( 1 ) )[2] ); - List list = session.createQuery( - "select id, description as descr, (select max(id) from Product2) as maximum from Product2" - ).setFirstResult( 2 ).setMaxResults( 2 ).list(); - assertEquals( 19, ( (Object[]) list.get( 1 ) )[2] ); - - list = session.createQuery( "select id, description, (select max(id) from Product2) from Product2 order by id" ) - .setFirstResult( 2 ).setMaxResults( 2 ).list(); - assertEquals( 2, list.size() ); - assertArrayEquals( new Object[] {12, "Kit12", 19}, (Object[]) list.get( 0 )); - assertArrayEquals( new Object[] {13, "Kit13", 19}, (Object[]) list.get( 1 )); - - tx.rollback(); - session.close(); + list = session.createQuery( "select id, description, (select max(id) from Product2) from Product2 order by id" ) + .setFirstResult( 2 ).setMaxResults( 2 ).list(); + assertEquals( 2, list.size() ); + assertArrayEquals( new Object[] {12, "Kit12", 19}, (Object[]) list.get( 0 )); + assertArrayEquals( new Object[] {13, "Kit13", 19}, (Object[]) list.get( 1 )); + } ); } @Test public void testPaginationWithHQL() { - Session session = openSession(); - Transaction tx = session.beginTransaction(); + doInHibernate( this::sessionFactory, session -> { + for ( int i = 20; i < 30; i++ ) { + session.persist( new Product2( i, "Kit" + i ) ); + } + session.flush(); + session.clear(); - for ( int i = 20; i < 30; i++ ) { - session.persist( new Product2( i, "Kit" + i ) ); - } - session.flush(); - session.clear(); - - List list = session.createQuery( "from Product2 order by id" ).setFirstResult( 3 ).setMaxResults( 2 ).list(); - assertEquals( Arrays.asList( new Product2( 23, "Kit23" ), new Product2( 24, "Kit24" ) ), list ); - - tx.rollback(); - session.close(); + List list = session.createQuery( "from Product2 order by id" ).setFirstResult( 3 ).setMaxResults( 2 ).list(); + assertEquals( Arrays.asList( new Product2( 23, "Kit23" ), new Product2( 24, "Kit24" ) ), list ); + } ); } @Test @TestForIssue(jiraKey = "HHH-7370") public void testPaginationWithMaxOnly() { - Session session = openSession(); - Transaction tx = session.beginTransaction(); + doInHibernate( this::sessionFactory, session -> { + for ( int i = 30; i < 40; i++ ) { + session.persist( new Product2( i, "Kit" + i ) ); + } + session.flush(); + session.clear(); - for ( int i = 30; i < 40; i++ ) { - session.persist( new Product2( i, "Kit" + i ) ); - } - session.flush(); - session.clear(); + List list = session.createQuery( "from Product2 order by id" ).setFirstResult( 0 ).setMaxResults( 2 ).list(); + assertEquals( Arrays.asList( new Product2( 30, "Kit30" ), new Product2( 31, "Kit31" ) ), list ); - List list = session.createQuery( "from Product2 order by id" ).setFirstResult( 0 ).setMaxResults( 2 ).list(); - assertEquals( Arrays.asList( new Product2( 30, "Kit30" ), new Product2( 31, "Kit31" ) ), list ); - - list = session.createQuery( "select distinct p from Product2 p order by p.id" ).setMaxResults( 1 ).list(); - assertEquals( Arrays.asList( new Product2( 30, "Kit30" ) ), list ); - - tx.rollback(); - session.close(); + list = session.createQuery( "select distinct p from Product2 p order by p.id" ).setMaxResults( 1 ).list(); + assertEquals( Collections.singletonList( new Product2( 30, "Kit30" ) ), list ); + } ); } @Test @TestForIssue(jiraKey = "HHH-6627") public void testPaginationWithAggregation() { - Session session = openSession(); - Transaction tx = session.beginTransaction(); + doInHibernate( this::sessionFactory, session -> { + // populating test data + Category category1 = new Category( 1, "Category1" ); + Category category2 = new Category( 2, "Category2" ); + Category category3 = new Category( 3, "Category3" ); + session.persist( category1 ); + session.persist( category2 ); + session.persist( category3 ); + session.flush(); + session.persist( new Product2( 1, "Kit1", category1 ) ); + session.persist( new Product2( 2, "Kit2", category1 ) ); + session.persist( new Product2( 3, "Kit3", category1 ) ); + session.persist( new Product2( 4, "Kit4", category2 ) ); + session.persist( new Product2( 5, "Kit5", category2 ) ); + session.persist( new Product2( 6, "Kit6", category3 ) ); + session.flush(); + session.clear(); - // populating test data - Category category1 = new Category( 1, "Category1" ); - Category category2 = new Category( 2, "Category2" ); - Category category3 = new Category( 3, "Category3" ); - session.persist( category1 ); - session.persist( category2 ); - session.persist( category3 ); - session.flush(); - session.persist( new Product2( 1, "Kit1", category1 ) ); - session.persist( new Product2( 2, "Kit2", category1 ) ); - session.persist( new Product2( 3, "Kit3", category1 ) ); - session.persist( new Product2( 4, "Kit4", category2 ) ); - session.persist( new Product2( 5, "Kit5", category2 ) ); - session.persist( new Product2( 6, "Kit6", category3 ) ); - session.flush(); - session.clear(); + // count number of products in each category + List result = session.createCriteria( Category.class, "c" ).createAlias( "products", "p" ) + .setProjection( + Projections.projectionList() + .add( Projections.groupProperty( "c.id" ) ) + .add( Projections.countDistinct( "p.id" ) ) + ) + .addOrder( Order.asc( "c.id" ) ) + .setFirstResult( 1 ).setMaxResults( 3 ).list(); - // count number of products in each category - List result = session.createCriteria( Category.class, "c" ).createAlias( "products", "p" ) - .setProjection( - Projections.projectionList() - .add( Projections.groupProperty( "c.id" ) ) - .add( Projections.countDistinct( "p.id" ) ) - ) - .addOrder( Order.asc( "c.id" ) ) - .setFirstResult( 1 ).setMaxResults( 3 ).list(); - - assertEquals( 2, result.size() ); - assertArrayEquals( new Object[] { 2, 2L }, result.get( 0 ) ); // two products of second category - assertArrayEquals( new Object[] { 3, 1L }, result.get( 1 ) ); // one products of third category - - tx.rollback(); - session.close(); + assertEquals( 2, result.size() ); + assertArrayEquals( new Object[] { 2, 2L }, result.get( 0 ) ); // two products of second category + assertArrayEquals( new Object[] { 3, 1L }, result.get( 1 ) ); // one products of third category + } ); } @Test @TestForIssue(jiraKey = "HHH-7752") public void testPaginationWithFormulaSubquery() { - Session session = openSession(); - Transaction tx = session.beginTransaction(); + doInHibernate( this::sessionFactory, session -> { + // populating test data + Folder folder1 = new Folder( 1L, "Folder1" ); + Folder folder2 = new Folder( 2L, "Folder2" ); + Folder folder3 = new Folder( 3L, "Folder3" ); + session.persist( folder1 ); + session.persist( folder2 ); + session.persist( folder3 ); + session.flush(); + session.persist( new Contact( 1L, "Lukasz", "Antoniak", "owner", folder1 ) ); + session.persist( new Contact( 2L, "Kinga", "Mroz", "co-owner", folder2 ) ); + session.flush(); + session.clear(); + session.refresh( folder1 ); + session.refresh( folder2 ); + session.clear(); - // populating test data - Folder folder1 = new Folder( 1L, "Folder1" ); - Folder folder2 = new Folder( 2L, "Folder2" ); - Folder folder3 = new Folder( 3L, "Folder3" ); - session.persist( folder1 ); - session.persist( folder2 ); - session.persist( folder3 ); - session.flush(); - session.persist( new Contact( 1L, "Lukasz", "Antoniak", "owner", folder1 ) ); - session.persist( new Contact( 2L, "Kinga", "Mroz", "co-owner", folder2 ) ); - session.flush(); - session.clear(); - session.refresh( folder1 ); - session.refresh( folder2 ); - session.clear(); + List folderCount = session.createQuery( "select count(distinct f) from Folder f" ).setMaxResults( 1 ).list(); + assertEquals( Arrays.asList( 3L ), folderCount ); - List folderCount = session.createQuery( "select count(distinct f) from Folder f" ).setMaxResults( 1 ).list(); - assertEquals( Arrays.asList( 3L ), folderCount ); - - List distinctFolders = session.createQuery( "select distinct f from Folder f order by f.id desc" ) - .setFirstResult( 1 ).setMaxResults( 2 ).list(); - assertEquals( Arrays.asList( folder2, folder1 ), distinctFolders ); - - tx.rollback(); - session.close(); + List distinctFolders = session.createQuery( "select distinct f from Folder f order by f.id desc" ) + .setFirstResult( 1 ).setMaxResults( 2 ).list(); + assertEquals( Arrays.asList( folder2, folder1 ), distinctFolders ); + } ); } @Test @TestForIssue(jiraKey = "HHH-7781") public void testPaginationWithCastOperator() { - Session session = openSession(); - Transaction tx = session.beginTransaction(); + doInHibernate( this::sessionFactory, session -> { + for ( int i = 40; i < 50; i++ ) { + session.persist( new Product2( i, "Kit" + i ) ); + } + session.flush(); + session.clear(); - for ( int i = 40; i < 50; i++ ) { - session.persist( new Product2( i, "Kit" + i ) ); - } - session.flush(); - session.clear(); - - List list = session.createQuery( "select p.id, cast(p.id as string) as string_id from Product2 p order by p.id" ) - .setFirstResult( 1 ).setMaxResults( 2 ).list(); - assertEquals( 2, list.size() ); - assertArrayEquals( new Object[] { 41, "41" }, list.get( 0 ) ); - assertArrayEquals( new Object[] { 42, "42" }, list.get( 1 ) ); - - tx.rollback(); - session.close(); + List list = session.createQuery( "select p.id, cast(p.id as string) as string_id from Product2 p order by p.id" ) + .setFirstResult( 1 ).setMaxResults( 2 ).list(); + assertEquals( 2, list.size() ); + assertArrayEquals( new Object[] { 41, "41" }, list.get( 0 ) ); + assertArrayEquals( new Object[] { 42, "42" }, list.get( 1 ) ); + } ); } @Test @@ -309,30 +297,22 @@ public class SQLServerDialectTest extends BaseCoreFunctionalTestCase { kit.description = "m"; s.persist( kit ); s.getTransaction().commit(); - final Transaction tx = s.beginTransaction(); + final Transaction tx = s.beginTransaction(); Session s2 = openSession(); - Transaction tx2 = s2.beginTransaction(); + s2.beginTransaction(); - Product2 kit2 = (Product2) s2.byId( Product2.class ).load( kit.id ); + Product2 kit2 = s2.byId( Product2.class ).load( kit.id ); kit.description = "change!"; s.flush(); // creates write lock on kit until we end the transaction Thread thread = new Thread( - new Runnable() { - @Override - public void run() { - try { - Thread.sleep( 3000 ); - } - catch ( InterruptedException e ) { - e.printStackTrace(); - } - tx.commit(); - } + () -> { + sleep( TimeUnit.SECONDS.toMillis( 1 ) ); + tx.commit(); } ); @@ -348,10 +328,10 @@ public class SQLServerDialectTest extends BaseCoreFunctionalTestCase { } long end = System.currentTimeMillis(); thread.join(); - long differenceInMillisecs = end - start; + long differenceInMillis = end - start; assertTrue( - "Lock NoWait blocked for " + differenceInMillisecs + " ms, this is definitely to much for Nowait", - differenceInMillisecs < 2000 + "Lock NoWait blocked for " + differenceInMillis + " ms, this is definitely to much for Nowait", + differenceInMillis < 2000 ); s2.getTransaction().rollback(); @@ -360,10 +340,40 @@ public class SQLServerDialectTest extends BaseCoreFunctionalTestCase { s.getTransaction().commit(); } + + @Test + @TestForIssue(jiraKey = "HHH-10879") + public void testKeyReservedKeyword() { + doInHibernate( this::sessionFactory, session -> { + final KeyHolder keyHolder = new KeyHolder(); + keyHolder.key = 4000; + session.persist( keyHolder ); + } ); + } + @Override protected java.lang.Class[] getAnnotatedClasses() { return new java.lang.Class[] { - Product2.class, Category.class, Folder.class, Contact.class + Product2.class, Category.class, Folder.class, Contact.class, KeyHolder.class }; } + + @Entity(name = "KeyHolder") + public static class KeyHolder { + + @Id + public Integer key; + } + + @Override + protected boolean rebuildSessionFactoryOnError() { + return false; + } + + @Override + protected boolean isCleanupTestDataRequired() { + //SQL Server Driver does not deallocate connections right away + sleep(100); + return true; + } } diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseUnitTestCase.java b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseUnitTestCase.java index f2ca1c059b..1d95ecdda4 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseUnitTestCase.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseUnitTestCase.java @@ -62,4 +62,13 @@ public abstract class BaseUnitTestCase { } } } + + protected void sleep(long millis) { + try { + Thread.sleep( millis ); + } + catch ( InterruptedException e ) { + Thread.interrupted(); + } + } }