HHH-17797 support query hint database indexes

This commit is contained in:
jeonjonghyeok 2024-03-04 01:14:04 +09:00 committed by Christian Beikov
parent 096b667520
commit d21ddf31e5
2 changed files with 17 additions and 0 deletions

View File

@ -223,4 +223,14 @@ public interface HibernateHints {
* @since 6.3
*/
String HINT_QUERY_PLAN_CACHEABLE = "hibernate.query.plan.cacheable";
/**
* Hint for specifying a query hint to be appended to the
* SQL statement sent to the database.
*
* @see org.hibernate.query.spi.MutableQueryOptions#addDatabaseHint(String)
* @see org.hibernate.query.Query#addQueryHint
* @since 6.5
*/
String HINT_QUERY_DATABASE = "hibernate.query.database";
}

View File

@ -71,6 +71,7 @@
import static org.hibernate.jpa.HibernateHints.HINT_FLUSH_MODE;
import static org.hibernate.jpa.HibernateHints.HINT_FOLLOW_ON_LOCKING;
import static org.hibernate.jpa.HibernateHints.HINT_NATIVE_SPACES;
import static org.hibernate.jpa.HibernateHints.HINT_QUERY_DATABASE;
import static org.hibernate.jpa.HibernateHints.HINT_QUERY_PLAN_CACHEABLE;
import static org.hibernate.jpa.HibernateHints.HINT_TIMEOUT;
import static org.hibernate.jpa.LegacySpecHints.HINT_JAVAEE_CACHE_RETRIEVE_MODE;
@ -270,6 +271,9 @@ public final boolean applyHint(String hintName, Object value) {
case HINT_NATIVE_SPACES:
applySynchronizeSpacesHint( value );
return true;
case HINT_QUERY_DATABASE:
applyDatabaseHint( (String) value );
return true;
default:
if ( applySelectionHint( hintName, value ) || applyAdditionalPossibleHints( hintName, value ) ) {
return true;
@ -547,6 +551,9 @@ protected void applyFlushModeHint(FlushMode flushMode) {
setHibernateFlushMode( flushMode );
}
protected void applyDatabaseHint(String hint) {
getQueryOptions().addDatabaseHint( hint );
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Options