[hibernate-dev] Difference between Comment and Hint in Hibernate query

Steve Ebersole steve at hibernate.org
Tue Aug 1 09:07:29 EDT 2017


Query hints are hints for the database' s query parser/optimizer.

A comment is a... well a comment :)

On Tue, Aug 1, 2017, 6:37 AM Vlad Mihalcea <mihalcea.vlad at gmail.com> wrote:

> Hi,
>
> While working on integrating a Pull Request, I realized that the
> org.hibernate.engine.spi.QueryParameters provides these two attributes:
>
> private String comment;
> private List<String> queryHints;
>
> Both these two are to be sent to the database, so why do we have both?
>
> I also noticed that only for Query Hints we do take into consideration DB
> specific query hint syntax:
>
> // Keep this here, rather than moving to Select.  Some Dialects may
> need the hint to be appended to the very
> // end or beginning of the finalized SQL statement, so wait until
> everything is processed.
> if ( parameters.getQueryHints() != null &&
> parameters.getQueryHints().size() > 0 ) {
>    sql = dialect.getQueryHintString( sql, parameters.getQueryHints() );
> }
>
> Shouldn't we only have either comment or queryHints? Or what is the
> difference between these two?
>
> Vlad
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>


More information about the hibernate-dev mailing list