Skip to content

HHH-19261 - query hints in Oracle are not concatenated with comma's, but with spaces #10588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 7.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.sql.Types;
import java.time.temporal.ChronoField;
import java.time.temporal.TemporalAccessor;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -119,8 +120,10 @@
import jakarta.persistence.GenerationType;
import jakarta.persistence.TemporalType;

import static java.lang.String.join;
import static java.util.regex.Pattern.CASE_INSENSITIVE;
import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor.extractUsingTemplate;
import static org.hibernate.internal.util.StringHelper.isEmpty;
import static org.hibernate.query.common.TemporalUnit.DAY;
import static org.hibernate.query.common.TemporalUnit.HOUR;
import static org.hibernate.query.common.TemporalUnit.MINUTE;
Expand Down Expand Up @@ -1275,6 +1278,17 @@ public boolean useFollowOnLocking(String sql, QueryOptions queryOptions) {
);
}

@Override
public String getQueryHintString(String query, List<String> hintList) {
if ( hintList.isEmpty() ) {
return query;
}
else {
final String hints = join( " ", hintList );
return isEmpty( hints ) ? query : getQueryHintString( query, hints );
}
}

@Override
public String getQueryHintString(String sql, String hints) {
final String statementType = statementType( sql );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,12 @@
import java.sql.Types;
import java.time.temporal.ChronoField;
import java.time.temporal.TemporalAccessor;
import java.util.List;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static java.lang.String.join;
import static java.util.regex.Pattern.CASE_INSENSITIVE;
import static org.hibernate.cfg.DialectSpecificSettings.ORACLE_USE_BINARY_FLOATS;
import static org.hibernate.dialect.type.OracleJdbcHelper.getArrayJdbcTypeConstructor;
Expand Down Expand Up @@ -1337,6 +1339,17 @@ public boolean useFollowOnLocking(String sql, QueryOptions queryOptions) {
|| queryOptions.hasLimit() && queryOptions.getLimit().getFirstRow() != null;
}

@Override
public String getQueryHintString(String query, List<String> hintList) {
if ( hintList.isEmpty() ) {
return query;
}
else {
final String hints = join( " ", hintList );
return isEmpty( hints ) ? query : getQueryHintString( query, hints );
}
}

@Override
public String getQueryHintString(String sql, String hints) {
final String statementType = statementType( sql );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void testQueryHint(SessionFactoryScope scope) {
} );

statementInspector.assertExecutedCount( 1 );
assertTrue( statementInspector.getSqlQueries().get( 0 ).contains( "select /*+ ALL_ROWS, USE_CONCAT */" ) );
assertTrue( statementInspector.getSqlQueries().get( 0 ).contains( "select /*+ ALL_ROWS USE_CONCAT */" ) );
statementInspector.clear();

// ensure the insertion logic can handle a comment appended to the front
Expand Down