Top Description Methods
org.hibernate.annotations

public @Interface SQLSelect

extends Annotation
Annotations
@Target:TYPE, FIELD, METHOD
@Retention:RUNTIME
Imports
jakarta.persistence.SqlResultSetMapping, java.lang.annotation.Retention, .Target

Specifies a custom SQL query to be used in place of the default SQL generated by Hibernate when an entity or collection is loaded from the database by id. This occurs when:

The given SQL statement must have exactly the number of JDBC ? parameters that Hibernate expects, that is, one for each column of:

  1. the primary key, in the case of an entity, or
  2. the foreign key, in the case of a collection.

Optionally, an explicit result set mapping may be specified. It should have:

  1. a single jakarta.persistence.EntityResult, if the SQL query loads an entity, one-to-many association, or many-to-many association, or
  2. a single jakarta.persistence.ColumnResult or jakarta.persistence.ConstructorResult, if the SQL query loads an collection of basic-typed values.

Implementation Note

This annotation is just an abbreviation for Loader together with NamedNativeQuery.

Author
Gavin King
Since
6.2
See Also
HQLSelect, DialectOverride.SQLSelect

Method Summary

Modifier and TypeMethod and Description
public String[]
querySpaces()

The query spaces involved in this query.

public SqlResultSetMapping
public String
sql()

The SQL SELECT statement.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

querySpacesback to summary
public String[] querySpaces()

The query spaces involved in this query.

See Also
org.hibernate.query.SynchronizeableQuery
resultSetMappingback to summary
public SqlResultSetMapping resultSetMapping()

A SqlResultSetMapping with a single jakarta.persistence.ColumnResult or jakarta.persistence.EntityResult.

sqlback to summary
public String sql()

The SQL SELECT statement.