Uploaded image for project: 'Hibernate ORM'
  1. HHH-11618

Support for Native/SQL Query Hints in Entity Mappings

    Details

    • Type: New Feature
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 5.2.9
    • Fix Version/s: None
    • Component/s: hibernate-core
    • Labels:
      None
    • backPortable:
      Backport?
    • Last commented by a user?:
      true
    • Sprint:

      Description

      When defining entity mappings, it would be really useful to be able to provide optimizer hints to associations.

      Much like the FetchType, the ability to provide a dialect specific query hints (i.e Oracle's +ALL_ROWS, +RESULT_CACHE etc.) for fetching would greatly improve performance in various implementations.

      //Consider the following:
      @Entity
      	public static class Employee {
      		@Id
      		@GeneratedValue
      		public long id;
      		
      		@ManyToOne(fetch = FetchType.EAGER, fetchQueryHints= {"RESULT_CACHE"} )
      		public Department department;
      	}
      

      Query created to select from Department table using Oracle dialect would include:

      SELECT /*+ RESULT_CACHE */
        department0_.name AS NAME1_30_ FROM Department AS department0_
      

      Thank you for your consideration.

        Attachments

          Issue links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: