HHH-13608 Oracle8iDialect should use CASE_INSENSITIVE pattern matching when checking the statement type

This commit is contained in:
Vlad Mihalcea 2019-09-02 09:31:15 +03:00 committed by Andrea Boriero
parent 21e79125e6
commit f08abf3628
2 changed files with 29 additions and 4 deletions

View File

@ -66,7 +66,7 @@ public class Oracle8iDialect extends Dialect {
private static final Pattern UNION_KEYWORD_PATTERN = Pattern.compile( "\\bunion\\b" );
private static final Pattern SQL_STATEMENT_TYPE_PATTERN = Pattern.compile("^(?:\\/\\*.*?\\*\\/)?\\s*(select|insert|update|delete)\\s+.*?");
private static final Pattern SQL_STATEMENT_TYPE_PATTERN = Pattern.compile("^(?:\\/\\*.*?\\*\\/)?\\s*(select|insert|update|delete)\\s+.*?", Pattern.CASE_INSENSITIVE);
private static final AbstractLimitHandler LIMIT_HANDLER = new AbstractLimitHandler() {
@Override

View File

@ -152,8 +152,33 @@ public class QueryHintTest extends BaseNonConfigCoreFunctionalTestCase {
assertTrue( sqlStatementInterceptor.getSqlQueries().get( 0 ).contains( "/* My_Query */ select /*+ ALL_ROWS */" ) );
sqlStatementInterceptor.clear();
}
@Test
@TestForIssue( jiraKey = "HHH-13608")
public void testQueryHintCaseInsensitive() {
sqlStatementInterceptor.clear();
doInHibernate( this::sessionFactory, s -> {
List results = s.createNativeQuery(
"SELECT e.id as id " +
"FROM Employee e " +
"JOIN Department d ON e.department_id = d.id " +
"WHERE d.name = :departmentName" )
.addQueryHint( "ALL_ROWS" )
.setComment( "My_Query" )
.setParameter( "departmentName", "Sales" )
.getResultList();
assertEquals(results.size(), 2);
} );
sqlStatementInterceptor.assertExecutedCount( 1 );
assertTrue( sqlStatementInterceptor.getSqlQueries().get( 0 ).contains( "/* My_Query */ SELECT /*+ ALL_ROWS */" ) );
sqlStatementInterceptor.clear();
}
@Entity
@Entity(name = "Employee")
public static class Employee {
@Id
@GeneratedValue
@ -162,8 +187,8 @@ public class QueryHintTest extends BaseNonConfigCoreFunctionalTestCase {
@ManyToOne(fetch = FetchType.LAZY)
public Department department;
}
@Entity
@Entity(name = "Department")
public static class Department {
@Id
@GeneratedValue