HHH-12787 - SessionJdbcBatchTest hangs with DB2
This commit is contained in:
parent
5f6c122a3e
commit
1192eed560
|
@ -9,6 +9,8 @@ package org.hibernate.test.agroal;
|
|||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.test.agroal.util.PreparedStatementSpyConnectionProvider;
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -28,6 +30,7 @@ import static org.mockito.Mockito.verify;
|
|||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class AgroalSkipAutoCommitTest extends BaseCoreFunctionalTestCase {
|
||||
|
||||
private PreparedStatementSpyConnectionProvider connectionProvider = new PreparedStatementSpyConnectionProvider();
|
||||
|
|
|
@ -20,41 +20,27 @@ import org.hibernate.dialect.H2Dialect;
|
|||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.jdbc.SQLStatementInterceptor;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||
import static org.hibernate.testing.transaction.TransactionUtil.setJdbcTimeout;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
public abstract class AbstractCriteriaLiteralHandlingModeTest extends BaseEntityManagerFunctionalTestCase {
|
||||
|
||||
private PreparedStatementSpyConnectionProvider connectionProvider;
|
||||
private SQLStatementInterceptor sqlStatementInterceptor;
|
||||
|
||||
@Override
|
||||
protected Map getConfig() {
|
||||
Map config = super.getConfig();
|
||||
config.put(
|
||||
org.hibernate.cfg.AvailableSettings.CONNECTION_PROVIDER,
|
||||
connectionProvider
|
||||
);
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildEntityManagerFactory() {
|
||||
connectionProvider = new PreparedStatementSpyConnectionProvider( false, false );
|
||||
super.buildEntityManagerFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseResources() {
|
||||
super.releaseResources();
|
||||
connectionProvider.stop();
|
||||
protected void addConfigOptions(Map options) {
|
||||
sqlStatementInterceptor = new SQLStatementInterceptor( options );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -101,12 +87,12 @@ public abstract class AbstractCriteriaLiteralHandlingModeTest extends BaseEntity
|
|||
entity.get( "name" )
|
||||
);
|
||||
|
||||
connectionProvider.clear();
|
||||
List<Tuple> tuples = entityManager.createQuery( query )
|
||||
.getResultList();
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
List<Tuple> tuples = entityManager.createQuery( query ).getResultList();
|
||||
assertEquals( 1, tuples.size() );
|
||||
|
||||
assertNotNull( connectionProvider.getPreparedStatement( expectedSQL() ) );
|
||||
sqlStatementInterceptor.assertExecuted( expectedSQL() );
|
||||
} );
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.hibernate.hql.internal.ast.QuerySyntaxException;
|
|||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
import org.hibernate.testing.jdbc.SQLStatementInterceptor;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -44,29 +44,12 @@ import static org.junit.Assert.fail;
|
|||
*/
|
||||
@RequiresDialect(H2Dialect.class)
|
||||
public class CriteriaLiteralsTest extends BaseEntityManagerFunctionalTestCase {
|
||||
|
||||
private PreparedStatementSpyConnectionProvider connectionProvider;
|
||||
|
||||
private SQLStatementInterceptor sqlStatementInterceptor;
|
||||
|
||||
@Override
|
||||
protected Map getConfig() {
|
||||
Map config = super.getConfig();
|
||||
config.put(
|
||||
org.hibernate.cfg.AvailableSettings.CONNECTION_PROVIDER,
|
||||
connectionProvider
|
||||
);
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildEntityManagerFactory() {
|
||||
connectionProvider = new PreparedStatementSpyConnectionProvider( false, false );
|
||||
super.buildEntityManagerFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseResources() {
|
||||
super.releaseResources();
|
||||
connectionProvider.stop();
|
||||
protected void addConfigOptions(Map options) {
|
||||
sqlStatementInterceptor = new SQLStatementInterceptor( options );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -128,16 +111,15 @@ public class CriteriaLiteralsTest extends BaseEntityManagerFunctionalTestCase {
|
|||
entity.get( "name" )
|
||||
);
|
||||
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.clear();
|
||||
List<Tuple> tuples = entityManager.createQuery( query )
|
||||
.getResultList();
|
||||
|
||||
assertEquals(
|
||||
1,
|
||||
connectionProvider.getPreparedStatements().size()
|
||||
sqlStatementInterceptor.getSqlQueries().size()
|
||||
);
|
||||
assertNotNull( connectionProvider.getPreparedStatement(
|
||||
"select 'abc' as col_0_0_, criteriali0_.name as col_1_0_ from Book criteriali0_ where criteriali0_.name=?" ) );
|
||||
sqlStatementInterceptor.assertExecuted("select 'abc' as col_0_0_, criteriali0_.name as col_1_0_ from Book criteriali0_ where criteriali0_.name=?");
|
||||
assertTrue( tuples.isEmpty() );
|
||||
} );
|
||||
}
|
||||
|
@ -178,12 +160,12 @@ public class CriteriaLiteralsTest extends BaseEntityManagerFunctionalTestCase {
|
|||
entity.get( "name" )
|
||||
);
|
||||
|
||||
connectionProvider.clear();
|
||||
List<Tuple> tuples = entityManager.createQuery( query )
|
||||
.getResultList();
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
List<Tuple> tuples = entityManager.createQuery( query ).getResultList();
|
||||
assertEquals( 1, tuples.size() );
|
||||
|
||||
assertNotNull( connectionProvider.getPreparedStatement(expectedSQL) );
|
||||
sqlStatementInterceptor.assertExecuted( expectedSQL );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -200,15 +182,13 @@ public class CriteriaLiteralsTest extends BaseEntityManagerFunctionalTestCase {
|
|||
), cb.equal( authors.index(), 0 ) )
|
||||
.select( authors.get( "name" ) );
|
||||
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.clear();
|
||||
entityManager.createQuery( query ).getResultList();
|
||||
assertEquals(
|
||||
1,
|
||||
connectionProvider.getPreparedStatements().size()
|
||||
);
|
||||
assertNotNull( connectionProvider.getPreparedStatement(
|
||||
"select authors1_.name as col_0_0_ from Book criteriali0_ inner join Author authors1_ on criteriali0_.id=authors1_.book_id where criteriali0_.name=? and authors1_.index_id=0" )
|
||||
sqlStatementInterceptor.getSqlQueries().size()
|
||||
);
|
||||
sqlStatementInterceptor.assertExecuted( "select authors1_.name as col_0_0_ from Book criteriali0_ inner join Author authors1_ on criteriali0_.id=authors1_.book_id where criteriali0_.name=? and authors1_.index_id=0" );
|
||||
} );
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ import org.hibernate.jpa.AvailableSettings;
|
|||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.jpa.test.Wallet;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -24,6 +26,7 @@ import static org.junit.Assert.assertTrue;
|
|||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class DisableDiscardPersistenceContextOnCloseTest extends BaseEntityManagerFunctionalTestCase {
|
||||
|
||||
private PreparedStatementSpyConnectionProvider connectionProvider = new PreparedStatementSpyConnectionProvider( false, false );
|
||||
|
|
|
@ -9,10 +9,14 @@ package org.hibernate.jpa.test.ejb3configuration;
|
|||
import java.util.Map;
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import org.hibernate.dialect.DB2Dialect;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.jpa.test.Wallet;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.SkipForDialect;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -23,6 +27,7 @@ import static org.junit.Assert.fail;
|
|||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class EnableDiscardPersistenceContextOnCloseTest extends BaseEntityManagerFunctionalTestCase {
|
||||
|
||||
private PreparedStatementSpyConnectionProvider connectionProvider = new PreparedStatementSpyConnectionProvider( false, false );
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.hibernate.jpa.QueryHints;
|
|||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.jdbc.SQLStatementInterceptor;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -36,28 +37,11 @@ import static org.junit.Assert.assertTrue;
|
|||
public class EntityGraphWithFetchAnnotationTest
|
||||
extends BaseEntityManagerFunctionalTestCase {
|
||||
|
||||
private PreparedStatementSpyConnectionProvider connectionProvider;
|
||||
private SQLStatementInterceptor sqlStatementInterceptor;
|
||||
|
||||
@Override
|
||||
protected Map getConfig() {
|
||||
Map config = super.getConfig();
|
||||
config.put(
|
||||
org.hibernate.cfg.AvailableSettings.CONNECTION_PROVIDER,
|
||||
connectionProvider
|
||||
);
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildEntityManagerFactory() {
|
||||
connectionProvider = new PreparedStatementSpyConnectionProvider( false, false );
|
||||
super.buildEntityManagerFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseResources() {
|
||||
super.releaseResources();
|
||||
connectionProvider.stop();
|
||||
protected void addConfigOptions(Map options) {
|
||||
sqlStatementInterceptor = new SQLStatementInterceptor( options );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -79,7 +63,7 @@ public class EntityGraphWithFetchAnnotationTest
|
|||
.createQuery( Order.class );
|
||||
criteriaQuery.from( Order.class );
|
||||
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
entityManager
|
||||
.createQuery( criteriaQuery )
|
||||
|
@ -87,7 +71,7 @@ public class EntityGraphWithFetchAnnotationTest
|
|||
.setMaxResults( 20 )
|
||||
.getResultList();
|
||||
|
||||
assertFalse( connectionProvider.getPreparedSQLStatements().get( 0 ).toLowerCase().contains( "left outer join" ) );
|
||||
assertFalse( sqlStatementInterceptor.getSqlQueries().get( 0 ).toLowerCase().contains( "left outer join" ) );
|
||||
} );
|
||||
}
|
||||
|
||||
|
@ -104,7 +88,7 @@ public class EntityGraphWithFetchAnnotationTest
|
|||
EntityGraph<Order> entityGraph = entityManager.createEntityGraph( Order.class );
|
||||
entityGraph.addAttributeNodes( "products" );
|
||||
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
entityManager
|
||||
.createQuery( criteriaQuery )
|
||||
|
@ -113,7 +97,7 @@ public class EntityGraphWithFetchAnnotationTest
|
|||
.setHint( QueryHints.HINT_FETCHGRAPH, entityGraph )
|
||||
.getResultList();
|
||||
|
||||
assertTrue( connectionProvider.getPreparedSQLStatements().get( 0 ).toLowerCase().contains( "left outer join" ) );
|
||||
assertTrue( sqlStatementInterceptor.getSqlQueries().get( 0 ).toLowerCase().contains( "left outer join" ) );
|
||||
} );
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@ import javax.persistence.LockModeType;
|
|||
import org.hibernate.Session;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
import org.hibernate.testing.transaction.TransactionUtil;
|
||||
|
@ -30,6 +32,7 @@ import static org.junit.Assert.fail;
|
|||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class StatementIsClosedAfterALockExceptionTest extends BaseEntityManagerFunctionalTestCase {
|
||||
|
||||
private static final PreparedStatementSpyConnectionProvider CONNECTION_PROVIDER = new PreparedStatementSpyConnectionProvider( false, false );
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
|||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.jdbc.SQLStatementInterceptor;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -41,32 +42,12 @@ import static org.junit.Assert.assertNotNull;
|
|||
@TestForIssue(jiraKey = "HHH-11640")
|
||||
public class NamedQueryCommentTest extends BaseEntityManagerFunctionalTestCase {
|
||||
|
||||
private PreparedStatementSpyConnectionProvider connectionProvider;
|
||||
private SQLStatementInterceptor sqlStatementInterceptor;
|
||||
|
||||
@Override
|
||||
protected Map getConfig() {
|
||||
Map config = super.getConfig();
|
||||
config.put(
|
||||
org.hibernate.cfg.AvailableSettings.CONNECTION_PROVIDER,
|
||||
connectionProvider
|
||||
);
|
||||
config.put(
|
||||
AvailableSettings.USE_SQL_COMMENTS,
|
||||
Boolean.TRUE.toString()
|
||||
);
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildEntityManagerFactory() {
|
||||
connectionProvider = new PreparedStatementSpyConnectionProvider( false, false );
|
||||
super.buildEntityManagerFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseResources() {
|
||||
super.releaseResources();
|
||||
connectionProvider.stop();
|
||||
protected void addConfigOptions(Map options) {
|
||||
sqlStatementInterceptor = new SQLStatementInterceptor( options );
|
||||
options.put( AvailableSettings.USE_SQL_COMMENTS, Boolean.TRUE.toString() );
|
||||
}
|
||||
|
||||
private static final String[] GAME_TITLES = { "Halo", "Grand Theft Auto", "NetHack" };
|
||||
|
@ -76,11 +57,6 @@ public class NamedQueryCommentTest extends BaseEntityManagerFunctionalTestCase {
|
|||
return new Class[] { Game.class };
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addConfigOptions(Map options) {
|
||||
options.put( AvailableSettings.USE_SQL_COMMENTS, Boolean.TRUE.toString() );
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
|
@ -101,22 +77,17 @@ public class NamedQueryCommentTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@Test
|
||||
public void testSelectNamedQueryWithSqlComment() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
TypedQuery<Game> query = entityManager.createNamedQuery( "SelectNamedQuery", Game.class );
|
||||
query.setParameter( "title", GAME_TITLES[0] );
|
||||
List<Game> list = query.getResultList();
|
||||
assertEquals( 1, list.size() );
|
||||
|
||||
assertEquals(
|
||||
1,
|
||||
connectionProvider.getPreparedStatements().size()
|
||||
);
|
||||
sqlStatementInterceptor.assertExecutedCount(1);
|
||||
|
||||
assertNotNull(
|
||||
connectionProvider.getPreparedStatement(
|
||||
"/* COMMENT_SELECT_INDEX_game_title */ select namedquery0_.id as id1_0_, namedquery0_.title as title2_0_ from game namedquery0_ where namedquery0_.title=?"
|
||||
)
|
||||
sqlStatementInterceptor.assertExecuted(
|
||||
"/* COMMENT_SELECT_INDEX_game_title */ select namedquery0_.id as id1_0_, namedquery0_.title as title2_0_ from game namedquery0_ where namedquery0_.title=?"
|
||||
);
|
||||
} );
|
||||
}
|
||||
|
@ -124,22 +95,18 @@ public class NamedQueryCommentTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@Test
|
||||
public void testSelectNamedNativeQueryWithSqlComment() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
TypedQuery<Game> query = entityManager.createNamedQuery( "SelectNamedNativeQuery", Game.class );
|
||||
query.setParameter( "title", GAME_TITLES[0] );
|
||||
List<Game> list = query.getResultList();
|
||||
assertEquals( 1, list.size() );
|
||||
|
||||
assertEquals(
|
||||
1,
|
||||
connectionProvider.getPreparedStatements().size()
|
||||
);
|
||||
sqlStatementInterceptor.assertExecutedCount(1);
|
||||
|
||||
assertNotNull(
|
||||
connectionProvider.getPreparedStatement(
|
||||
sqlStatementInterceptor.assertExecuted(
|
||||
"/* + INDEX (game idx_game_title) */ select * from game g where title = ?"
|
||||
)
|
||||
|
||||
);
|
||||
} );
|
||||
}
|
||||
|
@ -147,7 +114,7 @@ public class NamedQueryCommentTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@Test
|
||||
public void testUpdateNamedQueryWithSqlComment() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
Query query = entityManager.createNamedQuery( "UpdateNamedNativeQuery" );
|
||||
query.setParameter( "title", GAME_TITLES[0] );
|
||||
|
@ -155,15 +122,10 @@ public class NamedQueryCommentTest extends BaseEntityManagerFunctionalTestCase {
|
|||
int updateCount = query.executeUpdate();
|
||||
assertEquals( 1, updateCount );
|
||||
|
||||
assertEquals(
|
||||
1,
|
||||
connectionProvider.getPreparedStatements().size()
|
||||
);
|
||||
sqlStatementInterceptor.assertExecutedCount(1);
|
||||
|
||||
assertNotNull(
|
||||
connectionProvider.getPreparedStatement(
|
||||
sqlStatementInterceptor.assertExecuted(
|
||||
"/* COMMENT_INDEX_game_title */ update game set title = ? where id = ?"
|
||||
)
|
||||
);
|
||||
} );
|
||||
}
|
||||
|
@ -171,7 +133,7 @@ public class NamedQueryCommentTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@Test
|
||||
public void testUpdateNamedNativeQueryWithSqlComment() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
Query query = entityManager.createNamedQuery( "UpdateNamedNativeQuery" );
|
||||
query.setParameter( "title", GAME_TITLES[0] );
|
||||
|
@ -179,15 +141,10 @@ public class NamedQueryCommentTest extends BaseEntityManagerFunctionalTestCase {
|
|||
int updateCount = query.executeUpdate();
|
||||
assertEquals( 1, updateCount );
|
||||
|
||||
assertEquals(
|
||||
1,
|
||||
connectionProvider.getPreparedStatements().size()
|
||||
);
|
||||
sqlStatementInterceptor.assertExecutedCount(1);
|
||||
|
||||
assertNotNull(
|
||||
connectionProvider.getPreparedStatement(
|
||||
sqlStatementInterceptor.assertExecuted(
|
||||
"/* COMMENT_INDEX_game_title */ update game set title = ? where id = ?"
|
||||
)
|
||||
);
|
||||
} );
|
||||
}
|
||||
|
@ -196,7 +153,7 @@ public class NamedQueryCommentTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@RequiresDialect(Oracle8iDialect.class)
|
||||
public void testUpdateNamedNativeQueryWithQueryHintUsingOracle() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
Query query = entityManager.createNamedQuery( "UpdateNamedNativeQuery" );
|
||||
query.setParameter( "title", GAME_TITLES[0] );
|
||||
|
@ -205,15 +162,10 @@ public class NamedQueryCommentTest extends BaseEntityManagerFunctionalTestCase {
|
|||
int updateCount = query.executeUpdate();
|
||||
assertEquals( 1, updateCount );
|
||||
|
||||
assertEquals(
|
||||
1,
|
||||
connectionProvider.getPreparedStatements().size()
|
||||
);
|
||||
sqlStatementInterceptor.assertExecutedCount(1);
|
||||
|
||||
assertNotNull(
|
||||
connectionProvider.getPreparedStatement(
|
||||
sqlStatementInterceptor.assertExecuted(
|
||||
"/* COMMENT_INDEX_game_title */ update /*+ INDEX (game idx_game_id) */ game set title = ? where id = ?"
|
||||
)
|
||||
);
|
||||
} );
|
||||
}
|
||||
|
@ -222,7 +174,7 @@ public class NamedQueryCommentTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@RequiresDialect(H2Dialect.class)
|
||||
public void testUpdateNamedNativeQueryWithQueryHintUsingIndex() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
Query query = entityManager.createNamedQuery( "UpdateNamedNativeQuery" );
|
||||
query.setParameter( "title", GAME_TITLES[0] );
|
||||
|
@ -231,15 +183,10 @@ public class NamedQueryCommentTest extends BaseEntityManagerFunctionalTestCase {
|
|||
int updateCount = query.executeUpdate();
|
||||
assertEquals( 1, updateCount );
|
||||
|
||||
assertEquals(
|
||||
1,
|
||||
connectionProvider.getPreparedStatements().size()
|
||||
);
|
||||
sqlStatementInterceptor.assertExecutedCount(1);
|
||||
|
||||
assertNotNull(
|
||||
connectionProvider.getPreparedStatement(
|
||||
sqlStatementInterceptor.assertExecuted(
|
||||
"/* COMMENT_INDEX_game_title */ update game set title = ? where id = ?"
|
||||
)
|
||||
);
|
||||
} );
|
||||
}
|
||||
|
@ -249,7 +196,7 @@ public class NamedQueryCommentTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@RequiresDialect(H2Dialect.class)
|
||||
public void testSelectNamedNativeQueryWithQueryHintUsingIndex() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
Query query = entityManager.createNamedQuery( "SelectNamedQuery" );
|
||||
query.setParameter( "title", GAME_TITLES[0] );
|
||||
|
@ -257,16 +204,11 @@ public class NamedQueryCommentTest extends BaseEntityManagerFunctionalTestCase {
|
|||
List<Game> list = query.getResultList();
|
||||
assertEquals( 1, list.size() );
|
||||
|
||||
assertEquals(
|
||||
1,
|
||||
connectionProvider.getPreparedStatements().size()
|
||||
);
|
||||
sqlStatementInterceptor.assertExecutedCount(1);
|
||||
|
||||
assertNotNull(
|
||||
connectionProvider.getPreparedStatement(
|
||||
"/* COMMENT_SELECT_INDEX_game_title */ select namedquery0_.id as id1_0_, namedquery0_.title as title2_0_ from game namedquery0_ USE INDEX (idx_game_id) where namedquery0_.title=?"
|
||||
)
|
||||
);
|
||||
sqlStatementInterceptor.assertExecuted(
|
||||
"/* COMMENT_SELECT_INDEX_game_title */ select namedquery0_.id as id1_0_, namedquery0_.title as title2_0_ from game namedquery0_ USE INDEX (idx_game_id) where namedquery0_.title=?" )
|
||||
;
|
||||
} );
|
||||
}
|
||||
|
||||
|
|
|
@ -15,12 +15,11 @@ import org.hibernate.cfg.AvailableSettings;
|
|||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.jdbc.SQLStatementInterceptor;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
|
@ -29,18 +28,13 @@ import static org.junit.Assert.assertTrue;
|
|||
@TestForIssue( jiraKey = "HHH-12469" )
|
||||
public class InClauseParameterPaddingTest extends BaseEntityManagerFunctionalTestCase {
|
||||
|
||||
private PreparedStatementSpyConnectionProvider connectionProvider;
|
||||
private SQLStatementInterceptor sqlStatementInterceptor;
|
||||
|
||||
@Override
|
||||
public void buildEntityManagerFactory() {
|
||||
connectionProvider = new PreparedStatementSpyConnectionProvider();
|
||||
super.buildEntityManagerFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseResources() {
|
||||
super.releaseResources();
|
||||
connectionProvider.stop();
|
||||
protected void addConfigOptions(Map options) {
|
||||
sqlStatementInterceptor = new SQLStatementInterceptor( options );
|
||||
options.put( AvailableSettings.USE_SQL_COMMENTS, Boolean.TRUE.toString() );
|
||||
options.put( AvailableSettings.IN_CLAUSE_PARAMETER_PADDING, Boolean.TRUE.toString() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,15 +44,6 @@ public class InClauseParameterPaddingTest extends BaseEntityManagerFunctionalTes
|
|||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addConfigOptions(Map options) {
|
||||
options.put( AvailableSettings.IN_CLAUSE_PARAMETER_PADDING, Boolean.TRUE.toString() );
|
||||
options.put(
|
||||
org.hibernate.cfg.AvailableSettings.CONNECTION_PROVIDER,
|
||||
connectionProvider
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterEntityManagerFactoryBuilt() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
|
@ -87,7 +72,7 @@ public class InClauseParameterPaddingTest extends BaseEntityManagerFunctionalTes
|
|||
}
|
||||
|
||||
private void validateInClauseParameterPadding(String expectedInClause, Integer... ids) {
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
return entityManager.createQuery(
|
||||
|
@ -98,7 +83,7 @@ public class InClauseParameterPaddingTest extends BaseEntityManagerFunctionalTes
|
|||
.getResultList();
|
||||
} );
|
||||
|
||||
assertTrue(connectionProvider.getPreparedSQLStatements().get( 0 ).endsWith( expectedInClause ));
|
||||
assertTrue(sqlStatementInterceptor.getSqlQueries().get( 0 ).endsWith( expectedInClause ));
|
||||
}
|
||||
|
||||
@Entity(name = "Person")
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
|||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.jdbc.SQLStatementInterceptor;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -32,20 +33,15 @@ import static org.junit.Assert.assertTrue;
|
|||
@RequiresDialect(H2Dialect.class)
|
||||
public class MaxInExpressionParameterPaddingTest extends BaseEntityManagerFunctionalTestCase {
|
||||
|
||||
private PreparedStatementSpyConnectionProvider connectionProvider;
|
||||
|
||||
public static final int MAX_COUNT = 15;
|
||||
|
||||
@Override
|
||||
public void buildEntityManagerFactory() {
|
||||
connectionProvider = new PreparedStatementSpyConnectionProvider();
|
||||
super.buildEntityManagerFactory();
|
||||
}
|
||||
private SQLStatementInterceptor sqlStatementInterceptor;
|
||||
|
||||
@Override
|
||||
public void releaseResources() {
|
||||
super.releaseResources();
|
||||
connectionProvider.stop();
|
||||
protected void addConfigOptions(Map options) {
|
||||
sqlStatementInterceptor = new SQLStatementInterceptor( options );
|
||||
options.put( AvailableSettings.USE_SQL_COMMENTS, Boolean.TRUE.toString() );
|
||||
options.put( AvailableSettings.IN_CLAUSE_PARAMETER_PADDING, Boolean.TRUE.toString() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,15 +51,6 @@ public class MaxInExpressionParameterPaddingTest extends BaseEntityManagerFuncti
|
|||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addConfigOptions(Map options) {
|
||||
options.put( AvailableSettings.IN_CLAUSE_PARAMETER_PADDING, Boolean.TRUE.toString() );
|
||||
options.put(
|
||||
AvailableSettings.CONNECTION_PROVIDER,
|
||||
connectionProvider
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialect getDialect() {
|
||||
return new MaxCountInExpressionH2Dialect();
|
||||
|
@ -84,7 +71,7 @@ public class MaxInExpressionParameterPaddingTest extends BaseEntityManagerFuncti
|
|||
|
||||
@Test
|
||||
public void testInClauseParameterPadding() {
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
return entityManager.createQuery(
|
||||
|
@ -102,7 +89,7 @@ public class MaxInExpressionParameterPaddingTest extends BaseEntityManagerFuncti
|
|||
}
|
||||
expectedInClause.append( ")" );
|
||||
|
||||
assertTrue(connectionProvider.getPreparedSQLStatements().get( 0 ).endsWith( expectedInClause.toString() ));
|
||||
assertTrue(sqlStatementInterceptor.getSqlQueries().get( 0 ).endsWith( expectedInClause.toString() ));
|
||||
}
|
||||
|
||||
@Entity(name = "Person")
|
||||
|
|
|
@ -26,8 +26,6 @@ import static org.junit.Assert.fail;
|
|||
public class EmbeddableWithOneToMany_HHH_11302_xml_Test extends
|
||||
BaseEntityManagerFunctionalTestCase {
|
||||
|
||||
PreparedStatementSpyConnectionProvider connectionProvider = new PreparedStatementSpyConnectionProvider( false, false );
|
||||
|
||||
@Override
|
||||
public String[] getEjb3DD() {
|
||||
return new String[] {
|
||||
|
@ -45,15 +43,6 @@ public class EmbeddableWithOneToMany_HHH_11302_xml_Test extends
|
|||
"@OneToMany, @ManyToMany or @ElementCollection cannot be used inside an @Embeddable that is also contained within an @ElementCollection"
|
||||
) );
|
||||
}
|
||||
finally {
|
||||
connectionProvider.stop();
|
||||
}
|
||||
}
|
||||
|
||||
protected Map buildSettings() {
|
||||
Map settings = super.buildSettings();
|
||||
settings.put( AvailableSettings.CONNECTION_PROVIDER, connectionProvider );
|
||||
return settings;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -25,7 +25,9 @@ import org.hibernate.cfg.AvailableSettings;
|
|||
import org.hibernate.dialect.MySQL5Dialect;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
|
@ -40,6 +42,7 @@ import static org.junit.Assert.assertTrue;
|
|||
*/
|
||||
@TestForIssue(jiraKey = "HHH-11236")
|
||||
@RequiresDialect(MySQL5Dialect.class)
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class MySQLDropConstraintThrowsExceptionTest extends BaseUnitTestCase {
|
||||
|
||||
@Before
|
||||
|
|
|
@ -68,7 +68,10 @@ import static org.mockito.Mockito.verify;
|
|||
* @author Gavin King
|
||||
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
|
||||
*/
|
||||
@RequiresDialectFeature(DialectChecks.SupportsSequences.class)
|
||||
@RequiresDialectFeature({
|
||||
DialectChecks.SupportsSequences.class,
|
||||
DialectChecks.SupportsJdbcDriverProxying.class
|
||||
})
|
||||
public class CriteriaQueryTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
private PreparedStatementSpyConnectionProvider connectionProvider = new PreparedStatementSpyConnectionProvider( true, false );
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.hibernate.cfg.Environment;
|
|||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
||||
|
@ -41,17 +40,11 @@ public class ElementCollectionTest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
return new Class[] {Task.class};
|
||||
}
|
||||
|
||||
private PreparedStatementSpyConnectionProvider connectionProvider = new PreparedStatementSpyConnectionProvider( false, false );
|
||||
|
||||
@Override
|
||||
protected void addSettings(Map settings) {
|
||||
settings.put( Environment.ORDER_INSERTS, "true" );
|
||||
settings.put( Environment.STATEMENT_BATCH_SIZE, "10" );
|
||||
settings.put(
|
||||
org.hibernate.cfg.AvailableSettings.CONNECTION_PROVIDER,
|
||||
connectionProvider
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBatchOrdering() {
|
||||
|
@ -66,12 +59,6 @@ public class ElementCollectionTest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseResources() {
|
||||
super.releaseResources();
|
||||
connectionProvider.stop();
|
||||
}
|
||||
|
||||
@Entity
|
||||
@Table(name = "TASK")
|
||||
public static class Task {
|
||||
|
|
|
@ -22,6 +22,8 @@ import javax.persistence.SequenceGenerator;
|
|||
|
||||
import org.hibernate.cfg.Environment;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
|
@ -36,6 +38,7 @@ import static org.mockito.Mockito.verify;
|
|||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-9864")
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class InsertOrderingWithBidirectionalManyToMany
|
||||
extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ import javax.persistence.SequenceGenerator;
|
|||
|
||||
import org.hibernate.cfg.Environment;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
|
@ -34,6 +36,7 @@ import static org.mockito.Mockito.verify;
|
|||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-9864")
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class InsertOrderingWithBidirectionalMapsIdOneToOne
|
||||
extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@ import javax.persistence.SequenceGenerator;
|
|||
|
||||
import org.hibernate.cfg.Environment;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
|
@ -36,6 +38,7 @@ import static org.mockito.Mockito.verify;
|
|||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-9864")
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class InsertOrderingWithBidirectionalOneToMany
|
||||
extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@ package org.hibernate.test.insertordering;
|
|||
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
@ -25,6 +27,7 @@ import static org.mockito.Mockito.verify;
|
|||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-9864")
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class InsertOrderingWithBidirectionalOneToOne
|
||||
extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ import javax.persistence.Table;
|
|||
import org.hibernate.annotations.BatchSize;
|
||||
import org.hibernate.cfg.Environment;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
|
@ -42,6 +44,7 @@ import static org.junit.Assert.assertEquals;
|
|||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-9864")
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class InsertOrderingWithJoinedTableInheritance
|
||||
extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@ import javax.persistence.Table;
|
|||
import org.hibernate.annotations.BatchSize;
|
||||
import org.hibernate.cfg.Environment;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
|
@ -41,6 +43,7 @@ import static org.junit.Assert.assertEquals;
|
|||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-9864")
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class InsertOrderingWithJoinedTableMultiLevelInheritance
|
||||
extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@ import javax.persistence.SequenceGenerator;
|
|||
|
||||
import org.hibernate.cfg.Environment;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
|
@ -36,6 +38,7 @@ import static org.mockito.Mockito.verify;
|
|||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-9864")
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class InsertOrderingWithManyToOne
|
||||
extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@ import javax.persistence.SequenceGenerator;
|
|||
|
||||
import org.hibernate.cfg.Environment;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
|
@ -37,6 +39,7 @@ import static org.mockito.Mockito.verify;
|
|||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-11996")
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class InsertOrderingWithMultipleManyToOne
|
||||
extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ import javax.persistence.Table;
|
|||
import org.hibernate.annotations.BatchSize;
|
||||
import org.hibernate.cfg.Environment;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
|
@ -42,6 +44,7 @@ import static org.junit.Assert.assertEquals;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-9864")
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class InsertOrderingWithSingleTableInheritance
|
||||
extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ import javax.persistence.Table;
|
|||
import org.hibernate.annotations.BatchSize;
|
||||
import org.hibernate.cfg.Environment;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
|
@ -42,6 +44,7 @@ import static org.junit.Assert.assertEquals;
|
|||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-9864")
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class InsertOrderingWithTablePerClassInheritance
|
||||
extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ import javax.persistence.SequenceGenerator;
|
|||
|
||||
import org.hibernate.cfg.Environment;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
|
@ -33,6 +35,7 @@ import static org.mockito.Mockito.verify;
|
|||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-9864")
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class InsertOrderingWithUnidirectionalOneToOne
|
||||
extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
|
|
|
@ -15,7 +15,11 @@ import javax.persistence.Id;
|
|||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.dialect.DB2Dialect;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.SkipForDialect;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
import org.junit.Test;
|
||||
|
@ -27,6 +31,7 @@ import static org.mockito.Mockito.verify;
|
|||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class SessionJdbcBatchTest
|
||||
extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@ import org.hibernate.criterion.Restrictions;
|
|||
import org.hibernate.dialect.AbstractHANADialect;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.query.Query;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.jdbc.SQLStatementInterceptor;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -38,26 +38,12 @@ import org.junit.Test;
|
|||
@RequiresDialect(AbstractHANADialect.class)
|
||||
public class QueryHintHANATest extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
private PreparedStatementSpyConnectionProvider connectionProvider;
|
||||
private SQLStatementInterceptor sqlStatementInterceptor;
|
||||
|
||||
@Override
|
||||
protected void addSettings(Map settings) {
|
||||
settings.put( AvailableSettings.USE_SQL_COMMENTS, "true" );
|
||||
settings.put(
|
||||
org.hibernate.cfg.AvailableSettings.CONNECTION_PROVIDER,
|
||||
connectionProvider );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildResources() {
|
||||
connectionProvider = new PreparedStatementSpyConnectionProvider( false, false );
|
||||
super.buildResources();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseResources() {
|
||||
super.releaseResources();
|
||||
connectionProvider.stop();
|
||||
sqlStatementInterceptor = new SQLStatementInterceptor( settings );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -84,7 +70,7 @@ public class QueryHintHANATest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
@Test
|
||||
public void testQueryHint() {
|
||||
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
doInHibernate( this::sessionFactory, s -> {
|
||||
Query<Employee> query = s.createQuery( "FROM QueryHintHANATest$Employee e WHERE e.department.name = :departmentName", Employee.class )
|
||||
|
@ -95,11 +81,9 @@ public class QueryHintHANATest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
assertEquals( results.size(), 2 );
|
||||
} );
|
||||
|
||||
assertEquals(
|
||||
1,
|
||||
connectionProvider.getPreparedStatements().size() );
|
||||
assertThat( connectionProvider.getPreparedSQLStatements().get( 0 ), containsString( " with hint (NO_CS_JOIN)" ) );
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.assertExecutedCount( 1 );
|
||||
assertThat( sqlStatementInterceptor.getSqlQueries().get( 0 ), containsString( " with hint (NO_CS_JOIN)" ) );
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
// test multiple hints
|
||||
doInHibernate( this::sessionFactory, s -> {
|
||||
|
@ -112,11 +96,10 @@ public class QueryHintHANATest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
assertEquals( results.size(), 2 );
|
||||
} );
|
||||
|
||||
assertEquals(
|
||||
1,
|
||||
connectionProvider.getPreparedStatements().size() );
|
||||
assertThat( connectionProvider.getPreparedSQLStatements().get( 0 ), containsString( " with hint (NO_CS_JOIN,OPTIMIZE_METAMODEL)" ) );
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.assertExecutedCount( 1 );
|
||||
|
||||
assertThat( sqlStatementInterceptor.getSqlQueries().get( 0 ), containsString( " with hint (NO_CS_JOIN,OPTIMIZE_METAMODEL)" ) );
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
// ensure the insertion logic can handle a comment appended to the front
|
||||
doInHibernate( this::sessionFactory, s -> {
|
||||
|
@ -129,11 +112,10 @@ public class QueryHintHANATest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
assertEquals( results.size(), 2 );
|
||||
} );
|
||||
|
||||
assertEquals(
|
||||
1,
|
||||
connectionProvider.getPreparedStatements().size() );
|
||||
assertThat( connectionProvider.getPreparedSQLStatements().get( 0 ), containsString( " with hint (NO_CS_JOIN)" ) );
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.assertExecutedCount( 1 );
|
||||
|
||||
assertThat( sqlStatementInterceptor.getSqlQueries().get( 0 ), containsString( " with hint (NO_CS_JOIN)" ) );
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
// test Criteria
|
||||
doInHibernate( this::sessionFactory, s -> {
|
||||
|
@ -145,17 +127,16 @@ public class QueryHintHANATest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
assertEquals( results.size(), 2 );
|
||||
} );
|
||||
|
||||
assertEquals(
|
||||
1,
|
||||
connectionProvider.getPreparedStatements().size() );
|
||||
assertThat( connectionProvider.getPreparedSQLStatements().get( 0 ), containsString( " with hint (NO_CS_JOIN)" ) );
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.assertExecutedCount( 1 );
|
||||
|
||||
assertThat( sqlStatementInterceptor.getSqlQueries().get( 0 ), containsString( " with hint (NO_CS_JOIN)" ) );
|
||||
sqlStatementInterceptor.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-12362")
|
||||
public void testQueryHintAndComment() {
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
doInHibernate( this::sessionFactory, s -> {
|
||||
Query<Employee> query = s.createQuery( "FROM QueryHintHANATest$Employee e WHERE e.department.name = :departmentName", Employee.class )
|
||||
|
@ -167,12 +148,11 @@ public class QueryHintHANATest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
assertEquals( results.size(), 2 );
|
||||
} );
|
||||
|
||||
assertEquals(
|
||||
1,
|
||||
connectionProvider.getPreparedStatements().size() );
|
||||
assertThat( connectionProvider.getPreparedSQLStatements().get( 0 ), containsString( " with hint (NO_CS_JOIN)" ) );
|
||||
assertThat( connectionProvider.getPreparedSQLStatements().get( 0 ), containsString( "/* My_Query */ select" ) );
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.assertExecutedCount( 1 );
|
||||
|
||||
assertThat( sqlStatementInterceptor.getSqlQueries().get( 0 ), containsString( " with hint (NO_CS_JOIN)" ) );
|
||||
assertThat( sqlStatementInterceptor.getSqlQueries().get( 0 ), containsString( "/* My_Query */ select" ) );
|
||||
sqlStatementInterceptor.clear();
|
||||
}
|
||||
|
||||
@Entity
|
||||
|
|
|
@ -23,8 +23,8 @@ import org.hibernate.query.Query;
|
|||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.jdbc.SQLStatementInterceptor;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
||||
|
@ -37,27 +37,12 @@ import static org.junit.Assert.assertTrue;
|
|||
@RequiresDialect( Oracle8iDialect.class )
|
||||
public class QueryHintTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
private PreparedStatementSpyConnectionProvider connectionProvider;
|
||||
private SQLStatementInterceptor sqlStatementInterceptor;
|
||||
|
||||
@Override
|
||||
protected void addSettings(Map settings) {
|
||||
settings.put( AvailableSettings.USE_SQL_COMMENTS, "true" );
|
||||
settings.put(
|
||||
org.hibernate.cfg.AvailableSettings.CONNECTION_PROVIDER,
|
||||
connectionProvider
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildResources() {
|
||||
connectionProvider = new PreparedStatementSpyConnectionProvider( false, false );
|
||||
super.buildResources();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseResources() {
|
||||
super.releaseResources();
|
||||
connectionProvider.stop();
|
||||
sqlStatementInterceptor = new SQLStatementInterceptor( settings );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -84,7 +69,7 @@ public class QueryHintTest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
@Test
|
||||
public void testQueryHint() {
|
||||
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
// test Query w/ a simple Oracle optimizer hint
|
||||
doInHibernate( this::sessionFactory, s -> {
|
||||
|
@ -96,12 +81,9 @@ public class QueryHintTest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
assertEquals(results.size(), 2);
|
||||
} );
|
||||
|
||||
assertEquals(
|
||||
1,
|
||||
connectionProvider.getPreparedStatements().size()
|
||||
);
|
||||
assertTrue( connectionProvider.getPreparedSQLStatements().get( 0 ).contains( "select /*+ ALL_ROWS */" ) );
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.assertExecutedCount( 1 );
|
||||
assertTrue( sqlStatementInterceptor.getSqlQueries().get( 0 ).contains( "select /*+ ALL_ROWS */" ) );
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
// test multiple hints
|
||||
doInHibernate( this::sessionFactory, s -> {
|
||||
|
@ -114,12 +96,9 @@ public class QueryHintTest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
assertEquals(results.size(), 2);
|
||||
} );
|
||||
|
||||
assertEquals(
|
||||
1,
|
||||
connectionProvider.getPreparedStatements().size()
|
||||
);
|
||||
assertTrue( connectionProvider.getPreparedSQLStatements().get( 0 ).contains( "select /*+ ALL_ROWS, USE_CONCAT */" ) );
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.assertExecutedCount( 1 );
|
||||
assertTrue( sqlStatementInterceptor.getSqlQueries().get( 0 ).contains( "select /*+ ALL_ROWS, USE_CONCAT */" ) );
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
// ensure the insertion logic can handle a comment appended to the front
|
||||
doInHibernate( this::sessionFactory, s -> {
|
||||
|
@ -132,12 +111,10 @@ public class QueryHintTest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
assertEquals(results.size(), 2);
|
||||
} );
|
||||
|
||||
assertEquals(
|
||||
1,
|
||||
connectionProvider.getPreparedStatements().size()
|
||||
);
|
||||
assertTrue( connectionProvider.getPreparedSQLStatements().get( 0 ).contains( "select /*+ ALL_ROWS */" ) );
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.assertExecutedCount( 1 );
|
||||
|
||||
assertTrue( sqlStatementInterceptor.getSqlQueries().get( 0 ).contains( "select /*+ ALL_ROWS */" ) );
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
// test Criteria
|
||||
doInHibernate( this::sessionFactory, s -> {
|
||||
|
@ -149,18 +126,16 @@ public class QueryHintTest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
assertEquals(results.size(), 2);
|
||||
} );
|
||||
|
||||
assertEquals(
|
||||
1,
|
||||
connectionProvider.getPreparedStatements().size()
|
||||
);
|
||||
assertTrue( connectionProvider.getPreparedSQLStatements().get( 0 ).contains( "select /*+ ALL_ROWS */" ) );
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.assertExecutedCount( 1 );
|
||||
|
||||
assertTrue( sqlStatementInterceptor.getSqlQueries().get( 0 ).contains( "select /*+ ALL_ROWS */" ) );
|
||||
sqlStatementInterceptor.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-12362" )
|
||||
public void testQueryHintAndComment() {
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.clear();
|
||||
|
||||
doInHibernate( this::sessionFactory, s -> {
|
||||
Query query = s.createQuery( "FROM QueryHintTest$Employee e WHERE e.department.name = :departmentName" )
|
||||
|
@ -172,12 +147,10 @@ public class QueryHintTest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
assertEquals(results.size(), 2);
|
||||
} );
|
||||
|
||||
assertEquals(
|
||||
1,
|
||||
connectionProvider.getPreparedStatements().size()
|
||||
);
|
||||
assertTrue( connectionProvider.getPreparedSQLStatements().get( 0 ).contains( "/* My_Query */ select /*+ ALL_ROWS */" ) );
|
||||
connectionProvider.clear();
|
||||
sqlStatementInterceptor.assertExecutedCount( 1 );
|
||||
|
||||
assertTrue( sqlStatementInterceptor.getSqlQueries().get( 0 ).contains( "/* My_Query */ select /*+ ALL_ROWS */" ) );
|
||||
sqlStatementInterceptor.clear();
|
||||
}
|
||||
|
||||
@Entity
|
||||
|
|
|
@ -19,6 +19,8 @@ import org.hibernate.jpa.QueryHints;
|
|||
import org.hibernate.query.NativeQuery;
|
||||
import org.hibernate.query.Query;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
|
@ -33,6 +35,7 @@ import static org.mockito.Mockito.verify;
|
|||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class QueryTimeOutTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
private static final PreparedStatementSpyConnectionProvider CONNECTION_PROVIDER = new PreparedStatementSpyConnectionProvider( true, false );
|
||||
|
|
|
@ -17,6 +17,8 @@ import javax.sql.DataSource;
|
|||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -30,6 +32,7 @@ import static org.mockito.Mockito.verify;
|
|||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public abstract class AbstractSkipAutoCommitTest extends BaseEntityManagerFunctionalTestCase {
|
||||
|
||||
private PreparedStatementSpyConnectionProvider connectionProvider =
|
||||
|
|
|
@ -23,6 +23,8 @@ import javax.persistence.Id;
|
|||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.dialect.MySQL5Dialect;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.SkipForDialect;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
|
@ -42,6 +44,7 @@ import static org.mockito.Mockito.verify;
|
|||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@SkipForDialect(MySQL5Dialect.class)
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class JdbcTimeCustomTimeZoneTest
|
||||
extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ import javax.persistence.Id;
|
|||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
import org.junit.Test;
|
||||
|
@ -31,6 +33,8 @@ import static org.mockito.Mockito.verify;
|
|||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
|
||||
public class JdbcTimeDefaultTimeZoneTest
|
||||
extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ import javax.persistence.Id;
|
|||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.dialect.MySQL5Dialect;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.SkipForDialect;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
|
@ -39,6 +41,7 @@ import static org.mockito.Mockito.verify;
|
|||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@SkipForDialect(MySQL5Dialect.class)
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class JdbcTimestampCustomSessionLevelTimeZoneTest
|
||||
extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ import javax.persistence.Id;
|
|||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.dialect.MySQL5Dialect;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.SkipForDialect;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
|
@ -39,6 +41,7 @@ import static org.mockito.Mockito.verify;
|
|||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@SkipForDialect(MySQL5Dialect.class)
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class JdbcTimestampCustomTimeZoneTest
|
||||
extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@ import javax.persistence.Id;
|
|||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
import org.junit.Test;
|
||||
|
@ -30,6 +32,7 @@ import static org.mockito.Mockito.verify;
|
|||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class JdbcTimestampDefaultTimeZoneTest
|
||||
extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@ import javax.persistence.Id;
|
|||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.hibernate.test.util.PreparedStatementSpyConnectionProvider;
|
||||
import org.junit.Test;
|
||||
|
@ -29,6 +31,7 @@ import static org.mockito.Mockito.verify;
|
|||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class)
|
||||
public class HikariCPSkipAutoCommitTest extends BaseCoreFunctionalTestCase {
|
||||
|
||||
private PreparedStatementSpyConnectionProvider connectionProvider =
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
package org.hibernate.testing;
|
||||
|
||||
import org.hibernate.dialect.DB2Dialect;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
|
||||
/**
|
||||
|
@ -247,4 +248,12 @@ abstract public class DialectChecks {
|
|||
return dialect.forceLobAsLastValue();
|
||||
}
|
||||
}
|
||||
|
||||
public static class SupportsJdbcDriverProxying implements DialectCheck {
|
||||
public boolean isMatch(Dialect dialect) {
|
||||
return !(
|
||||
dialect instanceof DB2Dialect
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,16 +7,21 @@
|
|||
package org.hibernate.testing.jdbc;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.boot.SessionFactoryBuilder;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.resource.jdbc.spi.StatementInspector;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
public class SQLStatementInterceptor {
|
||||
|
||||
private final LinkedList<String> sqlQueries = new LinkedList<>( );
|
||||
private final LinkedList<String> sqlQueries = new LinkedList<>();
|
||||
|
||||
public SQLStatementInterceptor(SessionFactoryBuilder sessionFactoryBuilder) {
|
||||
sessionFactoryBuilder.applyStatementInspector( (StatementInspector) sql -> {
|
||||
|
@ -25,7 +30,26 @@ public class SQLStatementInterceptor {
|
|||
} );
|
||||
}
|
||||
|
||||
public SQLStatementInterceptor(Map settings) {
|
||||
settings.put( AvailableSettings.STATEMENT_INSPECTOR, (StatementInspector) sql -> {
|
||||
sqlQueries.add( sql );
|
||||
return sql;
|
||||
} );
|
||||
}
|
||||
|
||||
public LinkedList<String> getSqlQueries() {
|
||||
return sqlQueries;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
sqlQueries.clear();
|
||||
}
|
||||
|
||||
public void assertExecuted(String expected) {
|
||||
assertTrue(sqlQueries.contains( expected ));
|
||||
}
|
||||
|
||||
public void assertExecutedCount(int expected) {
|
||||
assertEquals(expected, sqlQueries.size());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue