HHH-17389 Support pg_hint_plan hints for PostgreSQL
This commit is contained in:
parent
016dc56208
commit
adb86e7b7b
|
@ -58,6 +58,7 @@ import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
|||
import org.hibernate.procedure.internal.PostgreSQLCallableStatementSupport;
|
||||
import org.hibernate.procedure.spi.CallableStatementSupport;
|
||||
import org.hibernate.query.SemanticException;
|
||||
import org.hibernate.query.spi.QueryOptions;
|
||||
import org.hibernate.query.sqm.FetchClauseType;
|
||||
import org.hibernate.query.sqm.IntervalType;
|
||||
import org.hibernate.query.sqm.TemporalUnit;
|
||||
|
@ -1442,4 +1443,21 @@ public class PostgreSQLLegacyDialect extends Dialect {
|
|||
public int rowIdSqlType() {
|
||||
return OTHER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryHintString(String sql, String hints) {
|
||||
return "/*+ " + hints + " */ " + sql;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String addSqlHintOrComment(String sql, QueryOptions queryOptions, boolean commentsEnabled) {
|
||||
// PostgreSQL's extension pg_hint_plan needs the hint to be the first comment
|
||||
if ( commentsEnabled && queryOptions.getComment() != null ) {
|
||||
sql = prependComment( sql, queryOptions.getComment() );
|
||||
}
|
||||
if ( queryOptions.getDatabaseHints() != null && queryOptions.getDatabaseHints().size() > 0 ) {
|
||||
sql = getQueryHintString( sql, queryOptions.getDatabaseHints() );
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ import org.hibernate.persister.entity.mutation.EntityMutationTarget;
|
|||
import org.hibernate.procedure.internal.PostgreSQLCallableStatementSupport;
|
||||
import org.hibernate.procedure.spi.CallableStatementSupport;
|
||||
import org.hibernate.query.SemanticException;
|
||||
import org.hibernate.query.spi.QueryOptions;
|
||||
import org.hibernate.query.sqm.FetchClauseType;
|
||||
import org.hibernate.query.sqm.IntervalType;
|
||||
import org.hibernate.query.sqm.TemporalUnit;
|
||||
|
@ -1476,6 +1477,22 @@ public class PostgreSQLDialect extends Dialect {
|
|||
return OTHER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryHintString(String sql, String hints) {
|
||||
return "/*+ " + hints + " */ " + sql;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String addSqlHintOrComment(String sql, QueryOptions queryOptions, boolean commentsEnabled) {
|
||||
// PostgreSQL's extension pg_hint_plan needs the hint to be the first comment
|
||||
if ( commentsEnabled && queryOptions.getComment() != null ) {
|
||||
sql = prependComment( sql, queryOptions.getComment() );
|
||||
}
|
||||
if ( queryOptions.getDatabaseHints() != null && queryOptions.getDatabaseHints().size() > 0 ) {
|
||||
sql = getQueryHintString( sql, queryOptions.getDatabaseHints() );
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private interface OptionalTableUpdateStrategy {
|
||||
|
|
Loading…
Reference in New Issue