All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.annotations.HQLSelect Maven / Gradle / Ivy

There is a newer version: 6.6.2.Final
Show newest version
/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
 * See the lgpl.txt file in the root directory or .
 */
package org.hibernate.annotations;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * 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 {@link org.hibernate.Session#get} * or {@link org.hibernate.Session#find}. *
*

* The given {@linkplain #query HQL query} must have exactly one parameter * which accepts the {@linkplain jakarta.persistence.Id 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. * * @see SQLSelect * * @author Gavin King * * @since 6.2 * * @implNote This annotation is just an abbreviation for {@link Loader} * together with {@link NamedQuery}. */ @Target({TYPE, FIELD, METHOD}) @Retention(RUNTIME) public @interface HQLSelect { /** * The HQL {@code SELECT} statement. */ String query(); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy