Interface NativeQuery<T>

    • Method Detail

      • addScalar

        NativeQuery<T> addScalar​(String columnAlias)
        Declare a scalar query result. Hibernate will attempt to automatically detect the underlying type.

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

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

        NativeQuery<T> addScalar​(String columnAlias,
                                 BasicTypeReference<?> type)
        Declare a scalar query result.

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

        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

        NativeQuery<T> addScalar​(String columnAlias,
                                 BasicDomainType<?> type)
        Declare a scalar query result.

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

        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

        NativeQuery<T> addScalar​(String columnAlias,
                                 Class<?> javaType)
        Declare a scalar query result using the specified result type. Hibernate will implicitly determine an appropriate conversion, if it can. Otherwise an exception will be thrown
        Returns:
        this, for method chaining
        Since:
        6.0
      • addScalar

        <C> NativeQuery<T> addScalar​(String columnAlias,
                                     Class<C> relationalJavaType,
                                     AttributeConverter<?,​C> converter)
        Declare a scalar query result with an explicit conversion
        Parameters:
        relationalJavaType - The Java type expected by the converter as its "relational" type.
        converter - The conversion to apply. Consumes the JDBC value based on `relationalJavaType`.
        Returns:
        this, for method chaining
        Since:
        6.0
      • addScalar

        <O,​R> NativeQuery<T> addScalar​(String columnAlias,
                                             Class<O> domainJavaType,
                                             Class<R> jdbcJavaType,
                                             AttributeConverter<O,​R> converter)
        Declare a scalar query result with an explicit conversion
        Parameters:
        jdbcJavaType - The Java type expected by the converter as its "relational model" type.
        domainJavaType - The Java type expected by the converter as its "object model" type.
        converter - The conversion to apply. Consumes the JDBC value based on `relationalJavaType`.
        Returns:
        this, for method chaining
        Since:
        6.0
      • addScalar

        <C> NativeQuery<T> addScalar​(String columnAlias,
                                     Class<C> relationalJavaType,
                                     Class<? extends AttributeConverter<?,​C>> converter)
        Declare a scalar query result with an explicit conversion
        Parameters:
        relationalJavaType - The Java type expected by the converter as its "relational" type.
        converter - The conversion to apply. Consumes the JDBC value based on `relationalJavaType`.
        Returns:
        this, for method chaining
        Since:
        6.0
      • addScalar

        <O,​R> NativeQuery<T> addScalar​(String columnAlias,
                                             Class<O> domainJavaType,
                                             Class<R> jdbcJavaType,
                                             Class<? extends AttributeConverter<O,​R>> converter)
        Declare a scalar query result with an explicit conversion
        Parameters:
        jdbcJavaType - The Java type expected by the converter as its "relational model" type.
        domainJavaType - The Java type expected by the converter as its "object model" type.
        converter - The conversion to apply. Consumes the JDBC value based on `jdbcJavaType`.
        Returns:
        this, for method chaining
        Since:
        6.0
      • addAttributeResult

        NativeQuery<T> addAttributeResult​(String columnAlias,
                                          Class<?> entityJavaType,
                                          String attributePath)
        Defines a result based on a specified attribute. Differs from adding a scalar in that any conversions or other semantics defined on the attribute are automatically applied to the mapping
        Returns:
        this, for method chaining
        Since:
        6.0
      • addAttributeResult

        NativeQuery<T> addAttributeResult​(String columnAlias,
                                          String entityName,
                                          String attributePath)
        Defines a result based on a specified attribute. Differs from adding a scalar in that any conversions or other semantics defined on the attribute are automatically applied to the mapping
        Returns:
        this, for method chaining
        Since:
        6.0
      • addAttributeResult

        NativeQuery<T> addAttributeResult​(String columnAlias,
                                          SingularAttribute<?,​?> attribute)
        Defines a result based on a specified attribute. Differs from adding a scalar in that any conversions or other semantics defined on the attribute are automatically applied to the mapping. This form accepts the JPA Attribute mapping describing the attribute
        Returns:
        this, for method chaining
        Since:
        6.0
      • addRoot

        NativeQuery.RootReturn addRoot​(String tableAlias,
                                       String entityName)
        Add a new root return mapping, returning a NativeQuery.RootReturn to allow further definition.
        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.
        Since:
        3.6
      • addRoot

        NativeQuery.RootReturn addRoot​(String tableAlias,
                                       Class entityType)
        Add a new root return mapping, returning a NativeQuery.RootReturn to allow further definition.
        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.
        Since:
        3.6
      • addEntity

        NativeQuery<T> addEntity​(String entityName)
        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 addRoot(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

        NativeQuery<T> addEntity​(String tableAlias,
                                 String entityName)
        Declare a "root" entity.
        Parameters:
        tableAlias - The SQL table alias
        entityName - The entity name
        Returns:
        this, for method chaining
      • addEntity

        NativeQuery<T> addEntity​(String tableAlias,
                                 String entityName,
                                 LockMode lockMode)
        Declare a "root" entity, specifying a lock mode.
        Parameters:
        tableAlias - The SQL table alias
        entityName - The entity name
        lockMode - The lock mode for this return.
        Returns:
        this, for method chaining
      • addEntity

        NativeQuery<T> addEntity​(Class<?> entityType)
        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

        NativeQuery<T> addEntity​(String tableAlias,
                                 Class<?> entityType)
        Declare a "root" entity.
        Parameters:
        tableAlias - The SQL table alias
        entityType - The java type of the entity to add as a root
        Returns:
        this, for method chaining
      • addEntity

        NativeQuery<T> addEntity​(String tableAlias,
                                 Class<?> entityClass,
                                 LockMode lockMode)
        Declare a "root" entity, specifying a lock mode.
        Parameters:
        tableAlias - The SQL table alias
        entityClass - The entity Class
        lockMode - The lock mode for this return.
        Returns:
        this, for method chaining
      • addFetch

        NativeQuery.FetchReturn addFetch​(String tableAlias,
                                         String ownerTableAlias,
                                         String joinPropertyName)
        Declare a join fetch result.
        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.
        Since:
        3.6
      • addJoin

        NativeQuery<T> addJoin​(String tableAlias,
                               String path)
        Declare a join fetch result.
        Parameters:
        tableAlias - 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

        NativeQuery<T> addJoin​(String tableAlias,
                               String ownerTableAlias,
                               String joinPropertyName)
        Declare a join fetch result.
        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
        Since:
        3.6
      • addJoin

        NativeQuery<T> addJoin​(String tableAlias,
                               String path,
                               LockMode lockMode)
        Declare a join fetch result, specifying a lock mode.
        Parameters:
        tableAlias - 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
      • setTimeout

        NativeQuery<T> setTimeout​(int timeout)
        Description copied from interface: CommonQueryContract
        Set the query timeout in seconds. NOTE it is important to understand that any value set here is eventually passed directly through to the JDBC Statement which expressly disallows negative values. So negative values should be avoided as a general rule.
        Specified by:
        setTimeout in interface CommonQueryContract
        Specified by:
        setTimeout in interface Query<T>
        Parameters:
        timeout - the timeout in seconds
        Returns:
        this, for method chaining
        See Also:
        CommonQueryContract.getTimeout()
      • setLockMode

        NativeQuery<T> setLockMode​(String alias,
                                   LockMode lockMode)
        Description copied from interface: Query
        Set the LockMode to use for specific alias (as defined in the query's FROM clause).

        The alias-specific lock modes specified here are added to the query's internal LockOptions.

        The effect of these alias-specific LockModes is somewhat dependent on the driver/database in use. Generally speaking, for maximum portability, this method should only be used to mark that the rows corresponding to the given alias should be included in pessimistic locking (LockMode.PESSIMISTIC_WRITE).

        Specified by:
        setLockMode in interface Query<T>
        Parameters:
        alias - a query alias, or "this" for a collection filter
        lockMode - The lock mode to apply.
        Returns:
        this, for method chaining
        See Also:
        Query.getLockOptions()
      • setComment

        NativeQuery<T> setComment​(String comment)
        Description copied from interface: Query
        Set the comment for this query.
        Specified by:
        setComment in interface Query<T>
        Parameters:
        comment - The human-readable comment
        Returns:
        this, for method chaining
        See Also:
        Query.getComment()
      • addQueryHint

        NativeQuery<T> addQueryHint​(String hint)
        Description copied from interface: Query
        Add a DB query hint to the SQL. These differ from JPA's QueryHint and Query.getHints(), which is specific to the JPA implementation and ignores DB vendor-specific hints. Instead, these are intended solely for the vendor-specific hints, such as Oracle's optimizers. Multiple query hints are supported; the Dialect will determine concatenation and placement.
        Specified by:
        addQueryHint in interface Query<T>
        Parameters:
        hint - The database specific query hint to add.
      • setParameter

        NativeQuery<T> setParameter​(int position,
                                    Object value)
        Description copied from interface: Query
        Bind a positional query parameter using its inferred Type. If the parameter is defined in such a way that the Type cannot be inferred from its usage context then use of this form of binding is not allowed, and Query.setParameter(int, Object, AllowableParameterType) should be used instead
        Specified by:
        setParameter in interface Query
        Specified by:
        setParameter in interface Query<T>
        Specified by:
        setParameter in interface TypedQuery<T>
        Parameters:
        position - the position of the parameter in the query string, numbered from 0.
        value - the possibly-null parameter value
        Returns:
        this, for method chaining
      • setParameter

        <P> NativeQuery<T> setParameter​(QueryParameter<P> parameter,
                                        P val)
        Description copied from interface: Query
        Bind a query parameter using its inferred Type. If the parameter is defined in such a way that the Type cannot be inferred from its usage context then use of this form of binding is not allowed, and Query.setParameter(QueryParameter, Object, AllowableParameterType) should be used instead
        Specified by:
        setParameter in interface Query<T>
        Parameters:
        parameter - The query parameter memento
        val - the possibly-null parameter value
        Returns:
        this, for method chaining
      • setParameter

        NativeQuery<T> setParameter​(String name,
                                    Object val,
                                    TemporalType temporalType)
        Description copied from interface: Query
        Bind a named query parameter as some form of date/time using the indicated temporal-type.
        Specified by:
        setParameter in interface Query<T>
        Parameters:
        name - the parameter name
        val - the possibly-null parameter value
        temporalType - the temporal-type to use in binding the date/time
        Returns:
        this, for method chaining
      • setParameter

        NativeQuery<T> setParameter​(int position,
                                    Object val,
                                    TemporalType temporalType)
        Description copied from interface: Query
        Bind a positional query parameter as some form of date/time using the indicated temporal-type.
        Specified by:
        setParameter in interface Query<T>
        Parameters:
        position - the position of the parameter in the query string, numbered from 0.
        val - the possibly-null parameter value
        temporalType - the temporal-type to use in binding the date/time
        Returns:
        this, for method chaining
      • setParameter

        <P> NativeQuery<T> setParameter​(QueryParameter<P> parameter,
                                        P val,
                                        TemporalType temporalType)
        Description copied from interface: Query
        Bind a query parameter as some form of date/time using the indicated temporal-type.
        Specified by:
        setParameter in interface Query<T>
        Parameters:
        parameter - The query parameter memento
        val - the possibly-null parameter value
        temporalType - the temporal-type to use in binding the date/time
        Returns:
        this, for method chaining
      • setParameterList

        <P> NativeQuery<T> setParameterList​(QueryParameter<P> parameter,
                                            Collection<P> values)
        Description copied from interface: Query
        Bind multiple values to a query parameter using its inferred Type. The Hibernate type of the parameter values is first detected via the usage/position in the query and if not sufficient secondly guessed from the class of the first object in the collection. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).
        Specified by:
        setParameterList in interface Query<T>
        Parameters:
        parameter - the parameter memento
        values - a collection of values to list
        Returns:
        this, for method chaining
      • setParameterList

        NativeQuery<T> setParameterList​(String name,
                                        Collection<?> values)
        Description copied from interface: Query
        Bind multiple values to a named query parameter. The Hibernate type of the parameter is first detected via the usage/position in the query and if not sufficient secondly guessed from the class of the first object in the collection. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).
        Specified by:
        setParameterList in interface Query<T>
        Parameters:
        name - the name of the parameter
        values - a collection of values to list
        Returns:
        this, for method chaining
      • setParameterList

        <P> NativeQuery<T> setParameterList​(String name,
                                            Collection<? extends P> values,
                                            AllowableParameterType<P> type)
        Description copied from interface: Query
        Bind multiple values to a named query parameter. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).
        Specified by:
        setParameterList in interface Query<T>
        Parameters:
        name - the name of the parameter
        values - a collection of values to list
        type - the Hibernate allowable parameter type of the values
        Returns:
        this, for method chaining
      • setParameterList

        NativeQuery<T> setParameterList​(String name,
                                        Object[] values,
                                        AllowableParameterType<?> type)
        Description copied from interface: Query
        Bind multiple values to a named query parameter. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).
        Specified by:
        setParameterList in interface Query<T>
        Parameters:
        name - the name of the parameter
        values - a collection of values to list
        type - the Hibernate type of the values
        Returns:
        this, for method chaining
      • setParameterList

        NativeQuery<T> setParameterList​(String name,
                                        Object[] values)
        Description copied from interface: Query
        Bind multiple values to a named query parameter. The Hibernate type of the parameter is first detected via the usage/position in the query and if not sufficient secondly guessed from the class of the first object in the array. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).
        Specified by:
        setParameterList in interface Query<T>
        Parameters:
        name - the name of the parameter
        values - a collection of values to list
        Returns:
        this, for method chaining
      • setParameter

        <P> NativeQuery<T> setParameter​(String name,
                                        P val,
                                        AllowableParameterType<P> type)
        Description copied from interface: Query
        Bind a named query parameter using the supplied Type
        Specified by:
        setParameter in interface Query<T>
        Parameters:
        name - the name of the parameter
        val - the possibly-null parameter value
        type - the Hibernate allowable parameter type
        Returns:
        this, for method chaining
      • setParameter

        <P> NativeQuery<T> setParameter​(int position,
                                        P val,
                                        AllowableParameterType<P> type)
        Description copied from interface: Query
        Bind a value to a JDBC-style query parameter.
        Specified by:
        setParameter in interface Query<T>
        Parameters:
        position - the position of the parameter in the query string, numbered from 0.
        val - the possibly-null parameter value
        type - the Hibernate allowable parameter type
        Returns:
        this, for method chaining
      • setParameter

        <P> NativeQuery<T> setParameter​(QueryParameter<P> parameter,
                                        P val,
                                        AllowableParameterType<P> type)
        Description copied from interface: Query
        Bind a query parameter using the supplied Type
        Specified by:
        setParameter in interface Query<T>
        Parameters:
        parameter - The query parameter memento
        val - the possibly-null parameter value
        type - the Hibernate allowable parameter type
        Returns:
        this, for method chaining
      • setParameter

        <P> NativeQuery<T> setParameter​(String name,
                                        P val,
                                        BasicTypeReference<P> type)
        Description copied from interface: Query
        Bind a named query parameter using the supplied Type
        Specified by:
        setParameter in interface Query<T>
        Parameters:
        name - the name of the parameter
        val - the possibly-null parameter value
        type - the Hibernate allowable parameter type
        Returns:
        this, for method chaining
      • setParameter

        <P> NativeQuery<T> setParameter​(int position,
                                        P val,
                                        BasicTypeReference<P> type)
        Description copied from interface: Query
        Bind a value to a JDBC-style query parameter.
        Specified by:
        setParameter in interface Query<T>
        Parameters:
        position - the position of the parameter in the query string, numbered from 0.
        val - the possibly-null parameter value
        type - the Hibernate allowable parameter type
        Returns:
        this, for method chaining
      • setParameter

        <P> NativeQuery<T> setParameter​(QueryParameter<P> parameter,
                                        P val,
                                        BasicTypeReference<P> type)
        Description copied from interface: Query
        Bind a query parameter using the supplied Type
        Specified by:
        setParameter in interface Query<T>
        Parameters:
        parameter - The query parameter memento
        val - the possibly-null parameter value
        type - the Hibernate allowable parameter type
        Returns:
        this, for method chaining
      • setParameterList

        NativeQuery<T> setParameterList​(int position,
                                        Collection<?> values)
        Description copied from interface: Query
        Bind multiple values to a positional query parameter. The Hibernate type of the parameter is first detected via the usage/position in the query and if not sufficient secondly guessed from the class of the first object in the collection. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).
        Specified by:
        setParameterList in interface Query<T>
        Parameters:
        position - the parameter positional label
        values - a collection of values to list
        Returns:
        this, for method chaining
      • setParameterList

        <P> NativeQuery<T> setParameterList​(String name,
                                            Collection<? extends P> values,
                                            Class<P> type)
        Description copied from interface: Query
        Bind multiple values to a named query parameter. The Hibernate type of the parameter is first detected via the usage/position in the query and if not sufficient secondly guessed from the class of the first object in the collection. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).
        Specified by:
        setParameterList in interface Query<T>
        Parameters:
        name - the name of the parameter
        values - a collection of values to list
        Returns:
        this, for method chaining
      • setParameterList

        <P> NativeQuery<T> setParameterList​(int position,
                                            Collection<? extends P> values,
                                            Class<P> type)
        Description copied from interface: Query
        Bind multiple values to a positional query parameter. The Hibernate type of the parameter is first detected via the usage/position in the query and if not sufficient secondly guessed from the class of the first object in the collection. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).
        Specified by:
        setParameterList in interface Query<T>
        Parameters:
        position - the parameter positional label
        values - a collection of values to list
        Returns:
        this, for method chaining
      • setParameterList

        <P> NativeQuery<T> setParameterList​(int position,
                                            Collection<? extends P> values,
                                            AllowableParameterType<P> type)
        Description copied from interface: Query
        Bind multiple values to a positional query parameter. This is useful for binding a list of values to an expression such as foo.bar in (?1).
        Specified by:
        setParameterList in interface Query<T>
        Parameters:
        position - the parameter positional label
        values - a collection of values to list
        type - the Hibernate allowable parameter type of the values
        Returns:
        this, for method chaining
      • setParameterList

        NativeQuery<T> setParameterList​(int position,
                                        Object[] values,
                                        AllowableParameterType<?> type)
        Description copied from interface: Query
        Bind multiple values to a named query parameter. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).
        Specified by:
        setParameterList in interface Query<T>
        Parameters:
        position - the parameter positional label
        values - a collection of values to list
        type - the Hibernate type of the values
        Returns:
        this, for method chaining
      • setParameterList

        NativeQuery<T> setParameterList​(int position,
                                        Object[] values)
        Description copied from interface: Query
        Bind multiple values to a named query parameter. The Hibernate type of the parameter is first detected via the usage/position in the query and if not sufficient secondly guessed from the class of the first object in the array. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).
        Specified by:
        setParameterList in interface Query<T>
        Parameters:
        position - the parameter positional label
        values - a collection of values to list
        Returns:
        this, for method chaining
      • setProperties

        NativeQuery<T> setProperties​(Object bean)
        Description copied from interface: Query
        Bind the property values of the given bean to named parameters of the query, matching property names with parameter names and mapping property types to Hibernate types using heuristics.
        Specified by:
        setProperties in interface Query<T>
        Parameters:
        bean - any JavaBean or POJO
        Returns:
        this, for method chaining
      • setProperties

        NativeQuery<T> setProperties​(Map bean)
        Description copied from interface: Query
        Bind the values of the given Map for each named parameters of the query, matching key names with parameter names and mapping value types to Hibernate types using heuristics.
        Specified by:
        setProperties in interface Query<T>
        Parameters:
        bean - a java.util.Map
        Returns:
        this, for method chaining