Class SQLQueryImpl

All Implemented Interfaces:
Query, SQLQuery

public class SQLQueryImpl extends AbstractQueryImpl implements SQLQuery
Implementation of the SQLQuery contract.
  • Method Details

    • list

      public List list() throws HibernateException
      Description copied from interface: Query
      Return the query results as a List. If the query contains multiple results pre row, the results are returned in an instance of Object[].
      Specified by:
      list in interface Query
      Returns:
      the result list
      Throws:
      HibernateException
    • scroll

      public ScrollableResults scroll(ScrollMode scrollMode) throws HibernateException
      Description copied from interface: Query
      Return the query results as ScrollableResults. The scrollability of the returned results depends upon JDBC driver support for scrollable ResultSets.
      Specified by:
      scroll in interface Query
      Returns:
      the result iterator
      Throws:
      HibernateException
      See Also:
    • scroll

      public ScrollableResults scroll() throws HibernateException
      Description copied from interface: Query
      Return the query results as ScrollableResults. The scrollability of the returned results depends upon JDBC driver support for scrollable ResultSets.
      Specified by:
      scroll in interface Query
      Returns:
      the result iterator
      Throws:
      HibernateException
      See Also:
    • iterate

      public Iterator iterate() throws HibernateException
      Description copied from interface: Query
      Return the query results as an Iterator. If the query contains multiple results pre row, the results are returned in an instance of Object[].

      Entities returned as results are initialized on demand. The first SQL query returns identifiers only.
      Specified by:
      iterate in interface Query
      Returns:
      the result iterator
      Throws:
      HibernateException
    • getQueryParameters

      public QueryParameters getQueryParameters(Map namedParams)
      Overrides:
      getQueryParameters in class AbstractQueryImpl
    • verifyParameters

      protected void verifyParameters()
      Description copied from class: AbstractQueryImpl
      Perform parameter validation. Used prior to executing the encapsulated query.
      Overrides:
      verifyParameters in class AbstractQueryImpl
    • getReturnAliases

      public String[] getReturnAliases() throws HibernateException
      Description copied from interface: Query
      Return the HQL select clause aliases (if any)
      Specified by:
      getReturnAliases in interface Query
      Overrides:
      getReturnAliases in class AbstractQueryImpl
      Returns:
      an array of aliases as strings
      Throws:
      HibernateException
    • getReturnTypes

      public Type[] getReturnTypes() throws HibernateException
      Description copied from interface: Query
      Return the Hibernate types of the query result set.
      Specified by:
      getReturnTypes in interface Query
      Overrides:
      getReturnTypes in class AbstractQueryImpl
      Returns:
      an array of types
      Throws:
      HibernateException
    • setLockMode

      public Query setLockMode(String alias, LockMode lockMode)
      Description copied from interface: Query
      Set the lockmode for the objects idententified by the given alias that appears in the FROM clause.
      Specified by:
      setLockMode in interface Query
      Parameters:
      alias - a query alias, or this for a collection filter
    • setLockOptions

      public Query setLockOptions(LockOptions lockOptions)
      Description copied from interface: Query
      Set the lock options for the objects idententified by the given alias that appears in the FROM clause.
      Specified by:
      setLockOptions in interface Query
    • getLockOptions

      public LockOptions getLockOptions()
      Specified by:
      getLockOptions in class AbstractQueryImpl
    • addScalar

      public SQLQuery addScalar(String columnAlias, Type type)
      Description copied from interface: SQLQuery
      Declare a scalar query result.

      Functions like <return-scalar/> in hbm.xml or ColumnResult

      Specified by:
      addScalar in interface SQLQuery
      Parameters:
      columnAlias - The column alias in the result-set to be processed as a scalar result
      type - The Hibernate type as which to treat the value.
      Returns:
      this, for method chaining
    • addScalar

      public SQLQuery addScalar(String columnAlias)
      Description copied from interface: SQLQuery
      Declare a scalar query result. Hibernate will attempt to automatically detect the underlying type.

      Functions like <return-scalar/> in hbm.xml or ColumnResult

      Specified by:
      addScalar in interface SQLQuery
      Parameters:
      columnAlias - The column alias in the result-set to be processed as a scalar result
      Returns:
      this, for method chaining
    • addRoot

      public SQLQuery.RootReturn addRoot(String tableAlias, String entityName)
      Description copied from interface: SQLQuery
      Add a new root return mapping, returning a SQLQuery.RootReturn to allow further definition
      Specified by:
      addRoot in interface SQLQuery
      Parameters:
      tableAlias - The SQL table alias to map to this entity
      entityName - The name of the entity.
      Returns:
      The return config object for further control.
    • addRoot

      public SQLQuery.RootReturn addRoot(String tableAlias, Class entityType)
      Description copied from interface: SQLQuery
      Add a new root return mapping, returning a SQLQuery.RootReturn to allow further definition
      Specified by:
      addRoot in interface SQLQuery
      Parameters:
      tableAlias - The SQL table alias to map to this entity
      entityType - The java type of the entity.
      Returns:
      The return config object for further control.
    • addEntity

      public SQLQuery addEntity(String entityName)
      Description copied from interface: SQLQuery
      Declare a "root" entity, without specifying an alias. The expectation here is that the table alias is the same as the unqualified entity name

      Use SQLQuery.addRoot(java.lang.String, java.lang.String) if you need further control of the mapping

      Specified by:
      addEntity in interface SQLQuery
      Parameters:
      entityName - The entity name that is the root return of the query.
      Returns:
      this, for method chaining
    • addEntity

      public SQLQuery addEntity(String alias, String entityName)
      Description copied from interface: SQLQuery
      Declare a "root" entity
      Specified by:
      addEntity in interface SQLQuery
      Parameters:
      alias - The SQL table alias
      entityName - The entity name
      Returns:
      this, for method chaining
    • addEntity

      public SQLQuery addEntity(String alias, String entityName, LockMode lockMode)
      Description copied from interface: SQLQuery
      Declare a "root" entity, specifying a lock mode
      Specified by:
      addEntity in interface SQLQuery
      Parameters:
      alias - The SQL table alias
      entityName - The entity name
      lockMode - The lock mode for this return.
      Returns:
      this, for method chaining
    • addEntity

      public SQLQuery addEntity(Class entityType)
      Description copied from interface: SQLQuery
      Declare a "root" entity, without specifying an alias. The expectation here is that the table alias is the same as the unqualified entity name
      Specified by:
      addEntity in interface SQLQuery
      Parameters:
      entityType - The java type of the entity to add as a root
      Returns:
      this, for method chaining
    • addEntity

      public SQLQuery addEntity(String alias, Class entityClass)
      Description copied from interface: SQLQuery
      Declare a "root" entity
      Specified by:
      addEntity in interface SQLQuery
      Parameters:
      alias - The SQL table alias
      entityClass - The java type of the entity to add as a root
      Returns:
      this, for method chaining
    • addEntity

      public SQLQuery addEntity(String alias, Class entityClass, LockMode lockMode)
      Description copied from interface: SQLQuery
      Declare a "root" entity, specifying a lock mode
      Specified by:
      addEntity in interface SQLQuery
      Parameters:
      alias - The SQL table alias
      entityClass - The entity name
      lockMode - The lock mode for this return.
      Returns:
      this, for method chaining
    • addFetch

      public SQLQuery.FetchReturn addFetch(String tableAlias, String ownerTableAlias, String joinPropertyName)
      Description copied from interface: SQLQuery
      Declare a join fetch result.
      Specified by:
      addFetch in interface SQLQuery
      Parameters:
      tableAlias - The SQL table alias for the data to be mapped to this fetch
      ownerTableAlias - Identify the table alias of the owner of this association. Should match the alias of a previously added root or fetch
      joinPropertyName - The name of the property being join fetched.
      Returns:
      The return config object for further control.
    • addJoin

      public SQLQuery addJoin(String tableAlias, String ownerTableAlias, String joinPropertyName)
      Description copied from interface: SQLQuery
      Declare a join fetch result.
      Specified by:
      addJoin in interface SQLQuery
      Parameters:
      tableAlias - The SQL table alias for the data to be mapped to this fetch
      ownerTableAlias - Identify the table alias of the owner of this association. Should match the alias of a previously added root or fetch
      joinPropertyName - The name of the property being join fetched.
      Returns:
      this, for method chaining
    • addJoin

      public SQLQuery addJoin(String alias, String path)
      Description copied from interface: SQLQuery
      Declare a join fetch result.
      Specified by:
      addJoin in interface SQLQuery
      Parameters:
      alias - The SQL table alias for the data to be mapped to this fetch
      path - The association path ([owner-alias].[property-name]).
      Returns:
      this, for method chaining
    • addJoin

      public SQLQuery addJoin(String alias, String path, LockMode lockMode)
      Description copied from interface: SQLQuery
      Declare a join fetch result, specifying a lock mode
      Specified by:
      addJoin in interface SQLQuery
      Parameters:
      alias - The SQL table alias for the data to be mapped to this fetch
      path - The association path ([owner-alias].[property-name]).
      lockMode - The lock mode for this return.
      Returns:
      this, for method chaining
    • setResultSetMapping

      public SQLQuery setResultSetMapping(String name)
      Description copied from interface: SQLQuery
      Use a predefined named result-set mapping. This might be defined by a <result-set/> element in a Hibernate hbm.xml file or through a SqlResultSetMapping annotation.
      Specified by:
      setResultSetMapping in interface SQLQuery
      Parameters:
      name - The name of the mapping to use.
      Returns:
      this, for method chaining
    • addSynchronizedQuerySpace

      public SQLQuery addSynchronizedQuerySpace(String querySpace)
      Description copied from interface: SQLQuery
      Adds a query space (table name) for (a) auto-flush checking and (b) query result cache invalidation checking
      Specified by:
      addSynchronizedQuerySpace in interface SQLQuery
      Parameters:
      querySpace - The query space to be auto-flushed for this query.
      Returns:
      this, for method chaining
    • addSynchronizedEntityName

      public SQLQuery addSynchronizedEntityName(String entityName)
      Description copied from interface: SQLQuery
      Adds an entity name for (a) auto-flush checking and (b) query result cache invalidation checking. Same as SQLQuery.addSynchronizedQuerySpace(java.lang.String) for all tables associated with the given entity.
      Specified by:
      addSynchronizedEntityName in interface SQLQuery
      Parameters:
      entityName - The name of the entity upon whose defined query spaces we should additionally synchronize.
      Returns:
      this, for method chaining
    • addSynchronizedEntityClass

      public SQLQuery addSynchronizedEntityClass(Class entityClass)
      Description copied from interface: SQLQuery
      Adds an entity for (a) auto-flush checking and (b) query result cache invalidation checking. Same as SQLQuery.addSynchronizedQuerySpace(java.lang.String) for all tables associated with the given entity.
      Specified by:
      addSynchronizedEntityClass in interface SQLQuery
      Parameters:
      entityClass - The class of the entity upon whose defined query spaces we should additionally synchronize.
      Returns:
      this, for method chaining
    • executeUpdate

      public int executeUpdate() throws HibernateException
      Description copied from interface: Query
      Execute the update or delete statement.

      The semantics are compliant with the ejb3 Query.executeUpdate() method.
      Specified by:
      executeUpdate in interface Query
      Returns:
      The number of entities updated or deleted.
      Throws:
      HibernateException