Package org.hibernate.annotations
Annotation Type HQLSelect
-
@Target({TYPE,FIELD,METHOD}) @Retention(RUNTIME) public @interface HQLSelect
Specifies a custom HQL/JPQL query to be used in place of the default SQL generated by Hibernate when an entity or collection is fetched from the database by id. This occurs when:- an association to an entity is fetched lazily,
- a collection is fetched lazily, or
- when an entity is retrieved using
Session.get(java.lang.Class<T>, java.lang.Object)
orEntityManager.find(java.lang.Class<T>, java.lang.Object)
.
The given HQL query must have exactly one parameter which accepts the id of the entity or of the entity which owns the collection. It must return a single item in the select list, and that item must be the correct type of entity or collection element.
- Since:
- 6.2
- See Also:
SQLSelect
- Implementation Note:
- This annotation is just an abbreviation for
Loader
together withNamedQuery
.
-
-
Element Detail
-
query
String query
The HQLSELECT
statement.
-
-