Package org.hibernate
Interface SQLQuery
- All Superinterfaces:
Query
- All Known Implementing Classes:
SQLQueryImpl
Represents a "native sql" query and allows the user to define certain aspects about its execution, such as:
- result-set value mapping (see below)
-
Tables used via
addSynchronizedQuerySpace(java.lang.String),addSynchronizedEntityName(java.lang.String)andaddSynchronizedEntityClass(java.lang.Class). This allows Hibernate to properly know how to deal with auto-flush checking as well as cached query results if the results of the query are being cached.
- If this represents a named sql query, the mapping could be associated with the query as part of its metadata
- A pre-defined (defined in metadata and named) mapping can be associated with
setResultSetMapping(java.lang.String) - Defined locally per the various
addEntity(java.lang.String),addRoot(java.lang.String, java.lang.String),addJoin(java.lang.String, java.lang.String),addFetch(java.lang.String, java.lang.String, java.lang.String)andaddScalar(java.lang.String)methods
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAllows access to further control how join fetch returns are mapped back from result setsstatic interfaceAllows access to further control how properties within a root or join fetch are mapped back from the result set.static interfaceAllows access to further control how root returns are mapped back from result sets -
Method Summary
Modifier and TypeMethodDescriptionDeclare a "root" entity, without specifying an alias.Declare a "root" entity, without specifying an alias.Declare a "root" entityDeclare a "root" entity, specifying a lock modeDeclare a "root" entityDeclare a "root" entity, specifying a lock modeDeclare a join fetch result.Declare a join fetch result.Declare a join fetch result.Declare a join fetch result, specifying a lock modeAdd a new root return mapping, returning aSQLQuery.RootReturnto allow further definitionAdd a new root return mapping, returning aSQLQuery.RootReturnto allow further definitionDeclare a scalar query result.Declare a scalar query result.addSynchronizedEntityClass(Class entityClass) Adds an entity for (a) auto-flush checking and (b) query result cache invalidation checking.addSynchronizedEntityName(String entityName) Adds an entity name for (a) auto-flush checking and (b) query result cache invalidation checking.addSynchronizedQuerySpace(String querySpace) Adds a query space (table name) for (a) auto-flush checking and (b) query result cache invalidation checkingsetResultSetMapping(String name) Use a predefined named result-set mapping.Methods inherited from interface org.hibernate.Query
executeUpdate, getNamedParameters, getQueryString, getReturnAliases, getReturnTypes, isReadOnly, iterate, list, scroll, scroll, setBigDecimal, setBigDecimal, setBigInteger, setBigInteger, setBinary, setBinary, setBoolean, setBoolean, setByte, setByte, setCacheable, setCacheMode, setCacheRegion, setCalendar, setCalendar, setCalendarDate, setCalendarDate, setCharacter, setCharacter, setComment, setDate, setDate, setDouble, setDouble, setEntity, setEntity, setFetchSize, setFirstResult, setFloat, setFloat, setFlushMode, setInteger, setInteger, setLocale, setLocale, setLockMode, setLockOptions, setLong, setLong, setMaxResults, setParameter, setParameter, setParameter, setParameter, setParameterList, setParameterList, setParameterList, setParameterList, setParameters, setProperties, setProperties, setReadOnly, setResultTransformer, setSerializable, setSerializable, setShort, setShort, setString, setString, setText, setText, setTime, setTime, setTimeout, setTimestamp, setTimestamp, uniqueResult
-
Method Details
-
addSynchronizedQuerySpace
Adds a query space (table name) for (a) auto-flush checking and (b) query result cache invalidation checking- Parameters:
querySpace- The query space to be auto-flushed for this query.- Returns:
- this, for method chaining
-
addSynchronizedEntityName
Adds an entity name for (a) auto-flush checking and (b) query result cache invalidation checking. Same asaddSynchronizedQuerySpace(java.lang.String)for all tables associated with the given entity.- Parameters:
entityName- The name of the entity upon whose defined query spaces we should additionally synchronize.- Returns:
- this, for method chaining
- Throws:
MappingException- Indicates the given name could not be resolved as an entity
-
addSynchronizedEntityClass
Adds an entity for (a) auto-flush checking and (b) query result cache invalidation checking. Same asaddSynchronizedQuerySpace(java.lang.String)for all tables associated with the given entity.- Parameters:
entityClass- The class of the entity upon whose defined query spaces we should additionally synchronize.- Returns:
- this, for method chaining
- Throws:
MappingException- Indicates the given class could not be resolved as an entity
-
setResultSetMapping
Use a predefined named result-set mapping. This might be defined by a<result-set/>element in a Hibernate hbm.xml file or through aSqlResultSetMappingannotation.- Parameters:
name- The name of the mapping to use.- Returns:
- this, for method chaining
-
addScalar
Declare a scalar query result. Hibernate will attempt to automatically detect the underlying type. Functions like<return-scalar/>inhbm.xmlorColumnResult- Parameters:
columnAlias- The column alias in the result-set to be processed as a scalar result- Returns:
this, for method chaining
-
addScalar
Declare a scalar query result. Functions like<return-scalar/>inhbm.xmlorColumnResult- Parameters:
columnAlias- The column alias in the result-set to be processed as a scalar resulttype- The Hibernate type as which to treat the value.- Returns:
this, for method chaining
-
addRoot
Add a new root return mapping, returning aSQLQuery.RootReturnto allow further definition- Parameters:
tableAlias- The SQL table alias to map to this entityentityName- The name of the entity.- Returns:
- The return config object for further control.
- Since:
- 3.6
-
addRoot
Add a new root return mapping, returning aSQLQuery.RootReturnto allow further definition- Parameters:
tableAlias- The SQL table alias to map to this entityentityType- The java type of the entity.- Returns:
- The return config object for further control.
- Since:
- 3.6
-
addEntity
Declare a "root" entity, without specifying an alias. The expectation here is that the table alias is the same as the unqualified entity name UseaddRoot(java.lang.String, java.lang.String)if you need further control of the mapping- Parameters:
entityName- The entity name that is the root return of the query.- Returns:
this, for method chaining
-
addEntity
Declare a "root" entity- Parameters:
tableAlias- The SQL table aliasentityName- The entity name- Returns:
this, for method chaining
-
addEntity
Declare a "root" entity, specifying a lock mode- Parameters:
tableAlias- The SQL table aliasentityName- The entity namelockMode- The lock mode for this return.- Returns:
this, for method chaining
-
addEntity
Declare a "root" entity, without specifying an alias. The expectation here is that the table alias is the same as the unqualified entity name- Parameters:
entityType- The java type of the entity to add as a root- Returns:
this, for method chaining
-
addEntity
Declare a "root" entity- Parameters:
tableAlias- The SQL table aliasentityType- The java type of the entity to add as a root- Returns:
this, for method chaining
-
addEntity
Declare a "root" entity, specifying a lock mode- Parameters:
tableAlias- The SQL table aliasentityName- The entity namelockMode- The lock mode for this return.- Returns:
this, for method chaining
-
addFetch
Declare a join fetch result.- Parameters:
tableAlias- The SQL table alias for the data to be mapped to this fetchownerTableAlias- Identify the table alias of the owner of this association. Should match the alias of a previously added root or fetchjoinPropertyName- The name of the property being join fetched.- Returns:
- The return config object for further control.
- Since:
- 3.6
-
addJoin
Declare a join fetch result.- Parameters:
tableAlias- The SQL table alias for the data to be mapped to this fetchpath- The association path ([owner-alias].[property-name]).- Returns:
this, for method chaining
-
addJoin
Declare a join fetch result.- Parameters:
tableAlias- The SQL table alias for the data to be mapped to this fetchownerTableAlias- Identify the table alias of the owner of this association. Should match the alias of a previously added root or fetchjoinPropertyName- The name of the property being join fetched.- Returns:
this, for method chaining- Since:
- 3.6
-
addJoin
Declare a join fetch result, specifying a lock mode- Parameters:
tableAlias- The SQL table alias for the data to be mapped to this fetchpath- The association path ([owner-alias].[property-name]).lockMode- The lock mode for this return.- Returns:
this, for method chaining
-