Skip to content

Commit

Permalink
HHH-10195 fix QueryHintSQLServer2012Test
Browse files Browse the repository at this point in the history
(cherry picked from commit 06311d3)
  • Loading branch information
jmartisk authored and sebersole committed Oct 26, 2015
1 parent 01c3589 commit 1741e0f
Showing 1 changed file with 10 additions and 7 deletions.
Expand Up @@ -65,7 +65,7 @@ public void testQueryHint() {

// test Query w/ a simple SQLServer2012 optimizer hint
s.getTransaction().begin();
Query query = s.createQuery( "FROM QueryHintTest$Employee e WHERE e.department.name = :departmentName" ).addQueryHint( "MAXDOP 2" )
Query query = s.createQuery( "FROM QueryHintSQLServer2012Test$Employee e WHERE e.department.name = :departmentName" ).addQueryHint( "MAXDOP 2" )
.setParameter( "departmentName", "Sales" );
List results = query.list();
s.getTransaction().commit();
Expand All @@ -78,21 +78,25 @@ public void testQueryHint() {

// test multiple hints
s.getTransaction().begin();
query = s.createQuery( "FROM QueryHintTest$Employee e WHERE e.department.name = :departmentName" ).addQueryHint( "MAXDOP 2" )
.addQueryHint( "USE_CONCAT" ).setParameter( "departmentName", "Sales" );
query = s.createQuery( "FROM QueryHintSQLServer2012Test$Employee e WHERE e.department.name = :departmentName" )
.addQueryHint("MAXDOP 2")
.addQueryHint("CONCAT UNION")
.setParameter("departmentName", "Sales");
results = query.list();
s.getTransaction().commit();
s.clear();

assertEquals( results.size(), 2 );
assertTrue( QueryHintTestSQLServer2012Dialect.getProcessedSql().contains( "OPTION (MAXDOP 2)" ) );
assertTrue( QueryHintTestSQLServer2012Dialect.getProcessedSql().contains( "MAXDOP 2" ) );
assertTrue( QueryHintTestSQLServer2012Dialect.getProcessedSql().contains( "CONCAT UNION" ) );

QueryHintTestSQLServer2012Dialect.resetProcessedSql();

// ensure the insertion logic can handle a comment appended to the front
s.getTransaction().begin();
query = s.createQuery( "FROM QueryHintTest$Employee e WHERE e.department.name = :departmentName" ).setComment( "this is a test" )
.addQueryHint( "MAXDOP 2" ).setParameter( "departmentName", "Sales" );
query = s.createQuery( "FROM QueryHintSQLServer2012Test$Employee e WHERE e.department.name = :departmentName" ).setComment( "this is a test" )
.addQueryHint( "MAXDOP 2" )
.setParameter( "departmentName", "Sales" );
results = query.list();
s.getTransaction().commit();
s.clear();
Expand All @@ -112,7 +116,6 @@ public void testQueryHint() {

assertEquals( results.size(), 2 );
assertTrue( QueryHintTestSQLServer2012Dialect.getProcessedSql().contains( "OPTION (MAXDOP 2)" ) );
assertEquals( false, true );
}

/**
Expand Down

0 comments on commit 1741e0f

Please sign in to comment.