From a8201bacdb6772ee15c48f55a3404b082f6711a6 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Tue, 24 Aug 2021 09:45:10 +0200 Subject: [PATCH] Fix Sybase failing test --- .../orm/test/query/QueryTimeOutTest.java | 51 ++++++++++++++----- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/QueryTimeOutTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/QueryTimeOutTest.java index 5b9584ac1f..f8921e700b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/QueryTimeOutTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/QueryTimeOutTest.java @@ -8,12 +8,12 @@ package org.hibernate.orm.test.query; import java.sql.SQLException; import java.util.Map; - import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; import org.hibernate.cfg.AvailableSettings; +import org.hibernate.dialect.SybaseDialect; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.jpa.QueryHints; import org.hibernate.query.NativeQuery; @@ -38,7 +38,10 @@ import static org.mockito.Mockito.verify; @RequiresDialectFeature(DialectChecks.SupportsJdbcDriverProxying.class) public class QueryTimeOutTest extends BaseNonConfigCoreFunctionalTestCase { - private static final PreparedStatementSpyConnectionProvider CONNECTION_PROVIDER = new PreparedStatementSpyConnectionProvider( true, false ); + private static final PreparedStatementSpyConnectionProvider CONNECTION_PROVIDER = new PreparedStatementSpyConnectionProvider( + true, + false + ); private static final String QUERY = "update AnEntity set name = 'abc'"; @Override @@ -58,7 +61,7 @@ public class QueryTimeOutTest extends BaseNonConfigCoreFunctionalTestCase { } @Test - @TestForIssue( jiraKey = "HHH-12075") + @TestForIssue(jiraKey = "HHH-12075") public void testCreateQuerySetTimeout() { doInHibernate( this::sessionFactory, session -> { @@ -67,7 +70,19 @@ public class QueryTimeOutTest extends BaseNonConfigCoreFunctionalTestCase { query.executeUpdate(); try { - verify( CONNECTION_PROVIDER.getPreparedStatement( QUERY ), times( 1 ) ).setQueryTimeout( 123 ); + if ( getDialect() instanceof SybaseDialect ) { + verify( + CONNECTION_PROVIDER.getPreparedStatement( + "update AnEntity set AnEntity.name = 'abc'" ), + times( 1 ) + ).setQueryTimeout( 123 ); + } + else { + verify( + CONNECTION_PROVIDER.getPreparedStatement( QUERY ), + times( 1 ) + ).setQueryTimeout( 123 ); + } } catch (SQLException ex) { fail( "should not have thrown exception" ); @@ -77,7 +92,7 @@ public class QueryTimeOutTest extends BaseNonConfigCoreFunctionalTestCase { } @Test - @TestForIssue( jiraKey = "HHH-12075") + @TestForIssue(jiraKey = "HHH-12075") public void testCreateQuerySetTimeoutHint() { doInHibernate( this::sessionFactory, session -> { @@ -86,7 +101,19 @@ public class QueryTimeOutTest extends BaseNonConfigCoreFunctionalTestCase { query.executeUpdate(); try { - verify( CONNECTION_PROVIDER.getPreparedStatement( QUERY ), times( 1 ) ).setQueryTimeout( 123 ); + if ( getDialect() instanceof SybaseDialect ) { + verify( + CONNECTION_PROVIDER.getPreparedStatement( + "update AnEntity set AnEntity.name = 'abc'" ), + times( 1 ) + ).setQueryTimeout( 123 ); + } + else { + verify( + CONNECTION_PROVIDER.getPreparedStatement( QUERY ), + times( 1 ) + ).setQueryTimeout( 123 ); + } } catch (SQLException ex) { fail( "should not have thrown exception" ); @@ -96,7 +123,7 @@ public class QueryTimeOutTest extends BaseNonConfigCoreFunctionalTestCase { } @Test - @TestForIssue( jiraKey = "HHH-12075") + @TestForIssue(jiraKey = "HHH-12075") public void testCreateNativeQuerySetTimeout() { doInHibernate( this::sessionFactory, session -> { @@ -115,7 +142,7 @@ public class QueryTimeOutTest extends BaseNonConfigCoreFunctionalTestCase { } @Test - @TestForIssue( jiraKey = "HHH-12075") + @TestForIssue(jiraKey = "HHH-12075") public void testCreateNativeQuerySetTimeoutHint() { doInHibernate( this::sessionFactory, session -> { @@ -134,7 +161,7 @@ public class QueryTimeOutTest extends BaseNonConfigCoreFunctionalTestCase { } @Test - @TestForIssue( jiraKey = "HHH-12075") + @TestForIssue(jiraKey = "HHH-12075") public void testCreateSQLQuerySetTimeout() { doInHibernate( this::sessionFactory, session -> { @@ -153,7 +180,7 @@ public class QueryTimeOutTest extends BaseNonConfigCoreFunctionalTestCase { } @Test - @TestForIssue( jiraKey = "HHH-12075") + @TestForIssue(jiraKey = "HHH-12075") public void testCreateSQLQuerySetTimeoutHint() { doInHibernate( this::sessionFactory, session -> { @@ -171,8 +198,8 @@ public class QueryTimeOutTest extends BaseNonConfigCoreFunctionalTestCase { ); } - @Entity(name = "AnEntity" ) - @Table(name = "AnEntity" ) + @Entity(name = "AnEntity") + @Table(name = "AnEntity") public static class AnEntity { @Id private int id;