[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-6123) Patch to support Oracle Hints in Hibernate queries

Raja (JIRA) noreply at atlassian.com
Wed Sep 7 23:37:03 EDT 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6123?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43479#comment-43479 ] 

Raja commented on HHH-6123:
---------------------------

This patch doesn't work if we have hql written with an alias name to the entity class because when applying the oracle hint it should use the same alias name mentioned in the SQL.

> Patch to support Oracle Hints in Hibernate queries
> --------------------------------------------------
>
>                 Key: HHH-6123
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6123
>             Project: Hibernate Core
>          Issue Type: Patch
>          Components: core
>    Affects Versions: 3.6.2
>            Reporter: Tad Smith
>            Assignee: Strong Liu
>         Attachments: hibernate-oracle-hints-patch-3.6.3-fixed.zip, hibernate-oracle-hints-patch-3.6.3.zip, hibernate-oracle-hints-patch.zip
>
>
> Supporting Oracle hints in Hibernate is a feature often requested by Hibernate users, though I'll admit should be used very rarely in practice.  Actually, I had a manager that demanded it if we were to continue using Hibernate (He was new to the project with a C++/DBA background.), so I modified Hibernate to support it.  I did this originally 2 years ago against Hibernate version 3.3.1.  I've just updated it to support Hibernate version 3.6.2.
> It would be great if this could be included in the Hibernate baseline.  It's a relatively minor change and the design follows existing Hibernate patterns.
> Thanks,
> Tad
> General Design:
> ========================
> I modeled the implementation after the org.hibernate.dialect.Dialect.getLimitString() method.  I added a new method to the org.hibernate.dialect.Dialect class called getQueryHintString().  I also modified the org.hibernate.Criteria and org.hibernate.Query interfaces to add a new method called setQueryHint().  This means you can create a Query from an HQL string and then apply the Oracle hint.
> Other Dialect class implementation would easy override the getQueryHintString() method to support hints for other databases.
> What's included in the patch:
> ===============================
> I've included the 9 classes that were modified to support Oracle hints.  I've also included a Maven POM file that should be able to generate the patch jar automatically and upload it to your Maven Repository.  Just change the artifactId from "hibernate-core" to "hibernate-core--OracleHintsPatch". (I'm relatively new to Maven and this has not received much testing, so feel free to improve upon it.)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list