接口 Query<R>

    • 方法详细资料

      • getProducer

        QueryProducer getProducer()
        Get the QueryProducer this Query originates from.
      • uniqueResultOptional

        Optional<R> uniqueResultOptional()
      • stream

        Stream<R> stream()
        Retrieve a Stream over the query results.

        In the initial implementation (5.2) this returns a simple sequential Stream. The plan is to return a a smarter stream in 6.x leveraging the SQM model.

        You should call BaseStream.close() after processing the stream so that the underlying resources are deallocated right away.

        返回:
        The results Stream
        从以下版本开始:
        5.2
      • applyGraph

        Query<R> applyGraph​(RootGraph graph,
                            GraphSemantic semantic)
        Apply the given graph using the given semantic
        参数:
        graph - The graph the apply.
        semantic - The semantic to use when applying the graph
        返回:
        this - for method chaining
      • setParameter

        Query<R> setParameter​(javax.persistence.Parameter<Instant> param,
                              Instant value,
                              javax.persistence.TemporalType temporalType)
      • setParameter

        Query<R> setParameter​(String name,
                              Instant value,
                              javax.persistence.TemporalType temporalType)
      • setParameter

        Query<R> setParameter​(int position,
                              Instant value,
                              javax.persistence.TemporalType temporalType)
      • setParameter

        Query<R> setParameter​(int position,
                              LocalDateTime value,
                              javax.persistence.TemporalType temporalType)
      • setParameter

        Query<R> setParameter​(int position,
                              ZonedDateTime value,
                              javax.persistence.TemporalType temporalType)
      • setParameter

        Query<R> setParameter​(int position,
                              OffsetDateTime value,
                              javax.persistence.TemporalType temporalType)
      • scroll

        ScrollableResults scroll()
        从接口复制的说明: Query
        Return the query results as ScrollableResults. The scrollability of the returned results depends upon JDBC driver support for scrollable ResultSets.

        You should call ScrollableResults.close() after processing the ScrollableResults so that the underlying resources are deallocated right away.

        指定者:
        scroll 在接口中 Query<R>
        返回:
        the result iterator
        另请参阅:
        ScrollableResults
      • scroll

        ScrollableResults scroll​(ScrollMode scrollMode)
        从接口复制的说明: Query
        Return the query results as ScrollableResults. The scrollability of the returned results depends upon JDBC driver support for scrollable ResultSets.

        You should call ScrollableResults.close() after processing the ScrollableResults so that the underlying resources are deallocated right away.

        指定者:
        scroll 在接口中 Query<R>
        参数:
        scrollMode - The scroll mode
        返回:
        the result iterator
        另请参阅:
        ScrollableResults, ScrollMode
      • list

        List<R> list()
        从接口复制的说明: Query
        Return the query results as a List. If the query contains multiple results per row, the results are returned in an instance of Object[].
        指定者:
        list 在接口中 Query<R>
        返回:
        the result list
      • getResultList

        default List<R> getResultList()
        指定者:
        getResultList 在接口中 javax.persistence.Query
        指定者:
        getResultList 在接口中 javax.persistence.TypedQuery<R>
      • uniqueResult

        R uniqueResult()
        从接口复制的说明: Query
        Convenience method to return a single instance that matches the query, or null if the query returns no results.
        指定者:
        uniqueResult 在接口中 Query<R>
        返回:
        the single result or null
      • getSingleResult

        default R getSingleResult()
        指定者:
        getSingleResult 在接口中 javax.persistence.Query
        指定者:
        getSingleResult 在接口中 javax.persistence.TypedQuery<R>
      • getCacheMode

        CacheMode getCacheMode()
        从接口复制的说明: Query
        Obtain the CacheMode in effect for this query. By default, the query inherits the CacheMode of the Session from which is originates. NOTE: The CacheMode here only effects reading/writing of the query cache, not the entity/collection caches.
        指定者:
        getCacheMode 在接口中 BasicQueryContract<R>
        指定者:
        getCacheMode 在接口中 Query<R>
        返回:
        The query CacheMode.
        另请参阅:
        Session.getCacheMode(), CacheMode
      • getCacheRegion

        String getCacheRegion()
        从接口复制的说明: Query
        Obtain the name of the second level query cache region in which query results will be stored (if they are cached, see the discussion on Query.isCacheable() for more information). null indicates that the default region should be used.
        指定者:
        getCacheRegion 在接口中 BasicQueryContract<R>
        指定者:
        getCacheRegion 在接口中 Query<R>
        返回:
        The specified cache region name into which query results should be placed; null indicates the default region.
      • getFetchSize

        Integer getFetchSize()
        从接口复制的说明: Query
        Obtain the JDBC fetch size hint in effect for this query. This value is eventually passed along to the JDBC query via Statement.setFetchSize(int). As defined b y JDBC, this value is a hint to the driver to indicate how many rows to fetch from the database when more rows are needed. NOTE : JDBC expressly defines this value as a hint. It may or may not have any effect on the actual query execution and ResultSet processing depending on the driver.
        指定者:
        getFetchSize 在接口中 BasicQueryContract<R>
        指定者:
        getFetchSize 在接口中 Query<R>
        返回:
        The timeout in seconds
        另请参阅:
        Statement.getFetchSize(), Statement.setFetchSize(int)
      • getComment

        String getComment()
        从接口复制的说明: Query
        Obtain the comment currently associated with this query. Provided SQL commenting is enabled (generally by enabling the hibernate.use_sql_comments config setting), this comment will also be added to the SQL query sent to the database. Often useful for identifying the source of troublesome queries on the database side.
        指定者:
        getComment 在接口中 Query<R>
        返回:
        The comment.
      • getQueryString

        String getQueryString()
        从接口复制的说明: Query
        Get the query string.
        指定者:
        getQueryString 在接口中 Query<R>
        返回:
        the query string
      • getParameterMetadata

        ParameterMetadata getParameterMetadata()
        从接口复制的说明: Query
        Access to information about query parameters.
        指定者:
        getParameterMetadata 在接口中 Query<R>
        返回:
        information about query parameters.
      • setMaxResults

        Query<R> setMaxResults​(int maxResult)
        指定者:
        setMaxResults 在接口中 javax.persistence.Query
        指定者:
        setMaxResults 在接口中 Query<R>
        指定者:
        setMaxResults 在接口中 javax.persistence.TypedQuery<R>
      • setFirstResult

        Query<R> setFirstResult​(int startPosition)
        指定者:
        setFirstResult 在接口中 javax.persistence.Query
        指定者:
        setFirstResult 在接口中 Query<R>
        指定者:
        setFirstResult 在接口中 javax.persistence.TypedQuery<R>
      • setHint

        Query<R> setHint​(String hintName,
                         Object value)
        指定者:
        setHint 在接口中 javax.persistence.Query
        指定者:
        setHint 在接口中 Query<R>
        指定者:
        setHint 在接口中 javax.persistence.TypedQuery<R>
      • setParameter

        <T> Query<R> setParameter​(javax.persistence.Parameter<T> param,
                                  T value)
        指定者:
        setParameter 在接口中 javax.persistence.Query
        指定者:
        setParameter 在接口中 Query<R>
        指定者:
        setParameter 在接口中 javax.persistence.TypedQuery<R>
      • setParameter

        Query<R> setParameter​(javax.persistence.Parameter<Calendar> param,
                              Calendar value,
                              javax.persistence.TemporalType temporalType)
        指定者:
        setParameter 在接口中 javax.persistence.Query
        指定者:
        setParameter 在接口中 Query<R>
        指定者:
        setParameter 在接口中 javax.persistence.TypedQuery<R>
      • setParameter

        Query<R> setParameter​(javax.persistence.Parameter<Date> param,
                              Date value,
                              javax.persistence.TemporalType temporalType)
        指定者:
        setParameter 在接口中 javax.persistence.Query
        指定者:
        setParameter 在接口中 Query<R>
        指定者:
        setParameter 在接口中 javax.persistence.TypedQuery<R>
      • setParameter

        Query<R> setParameter​(String name,
                              Object value)
        从接口复制的说明: Query
        Bind a named 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(String, Object, Type) should be used instead
        指定者:
        setParameter 在接口中 javax.persistence.Query
        指定者:
        setParameter 在接口中 Query<R>
        指定者:
        setParameter 在接口中 javax.persistence.TypedQuery<R>
        参数:
        name - the parameter name
        value - the (possibly-null) parameter value
        返回:
        this, for method chaining
      • setParameter

        Query<R> setParameter​(String name,
                              Object val,
                              Type type)
        从接口复制的说明: Query
        Bind a named query parameter using the supplied Type
        指定者:
        setParameter 在接口中 Query<R>
        参数:
        name - the name of the parameter
        val - the possibly-null parameter value
        type - the Hibernate type
        返回:
        this, for method chaining
      • setParameter

        Query<R> setParameter​(String name,
                              Calendar value,
                              javax.persistence.TemporalType temporalType)
        指定者:
        setParameter 在接口中 javax.persistence.Query
        指定者:
        setParameter 在接口中 Query<R>
        指定者:
        setParameter 在接口中 javax.persistence.TypedQuery<R>
      • setParameter

        Query<R> setParameter​(String name,
                              Date value,
                              javax.persistence.TemporalType temporalType)
        指定者:
        setParameter 在接口中 javax.persistence.Query
        指定者:
        setParameter 在接口中 Query<R>
        指定者:
        setParameter 在接口中 javax.persistence.TypedQuery<R>
      • setParameter

        Query<R> setParameter​(int position,
                              Object value)
        从接口复制的说明: 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, Type) should be used instead
        指定者:
        setParameter 在接口中 javax.persistence.Query
        指定者:
        setParameter 在接口中 Query<R>
        指定者:
        setParameter 在接口中 javax.persistence.TypedQuery<R>
        参数:
        position - the position of the parameter in the query string, numbered from 0.
        value - the possibly-null parameter value
        返回:
        this, for method chaining
      • setParameter

        Query<R> setParameter​(int position,
                              Calendar value,
                              javax.persistence.TemporalType temporalType)
        指定者:
        setParameter 在接口中 javax.persistence.Query
        指定者:
        setParameter 在接口中 Query<R>
        指定者:
        setParameter 在接口中 javax.persistence.TypedQuery<R>
      • setParameter

        Query<R> setParameter​(int position,
                              Date value,
                              javax.persistence.TemporalType temporalType)
        指定者:
        setParameter 在接口中 javax.persistence.Query
        指定者:
        setParameter 在接口中 Query<R>
        指定者:
        setParameter 在接口中 javax.persistence.TypedQuery<R>
      • setParameter

        <T> Query<R> setParameter​(QueryParameter<T> parameter,
                                  T val)
        从接口复制的说明: 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, Type) should be used instead
        指定者:
        setParameter 在接口中 Query<R>
        参数:
        parameter - The query parameter memento
        val - the possibly-null parameter value
        返回:
        this, for method chaining
      • setParameter

        <P> Query<R> setParameter​(int position,
                                  P val,
                                  javax.persistence.TemporalType temporalType)
        从接口复制的说明: Query
        Bind a positional query parameter as some form of date/time using the indicated temporal-type.
        指定者:
        setParameter 在接口中 Query<R>
        参数:
        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
        返回:
        this, for method chaining
      • setParameter

        <P> Query<R> setParameter​(QueryParameter<P> parameter,
                                  P val,
                                  Type type)
        从接口复制的说明: Query
        Bind a query parameter using the supplied Type
        指定者:
        setParameter 在接口中 Query<R>
        参数:
        parameter - The query parameter memento
        val - the possibly-null parameter value
        type - the Hibernate type
        返回:
        this, for method chaining
      • setParameter

        Query<R> setParameter​(int position,
                              Object val,
                              Type type)
        从接口复制的说明: Query
        Bind a value to a JDBC-style query parameter.
        指定者:
        setParameter 在接口中 Query<R>
        参数:
        position - the position of the parameter in the query string, numbered from 0.
        val - the possibly-null parameter value
        type - the Hibernate type
        返回:
        this, for method chaining
      • setParameter

        <P> Query<R> setParameter​(QueryParameter<P> parameter,
                                  P val,
                                  javax.persistence.TemporalType temporalType)
        从接口复制的说明: Query
        Bind a query parameter as some form of date/time using the indicated temporal-type.
        指定者:
        setParameter 在接口中 Query<R>
        参数:
        parameter - The query parameter memento
        val - the possibly-null parameter value
        temporalType - the temporal-type to use in binding the date/time
        返回:
        this, for method chaining
      • setParameter

        <P> Query<R> setParameter​(String name,
                                  P val,
                                  javax.persistence.TemporalType temporalType)
        从接口复制的说明: Query
        Bind a named query parameter as some form of date/time using the indicated temporal-type.
        指定者:
        setParameter 在接口中 Query<R>
        参数:
        name - the parameter name
        val - the possibly-null parameter value
        temporalType - the temporal-type to use in binding the date/time
        返回:
        this, for method chaining
      • setFlushMode

        Query<R> setFlushMode​(javax.persistence.FlushModeType flushMode)
        指定者:
        setFlushMode 在接口中 javax.persistence.Query
        指定者:
        setFlushMode 在接口中 Query<R>
        指定者:
        setFlushMode 在接口中 javax.persistence.TypedQuery<R>
      • setLockMode

        Query<R> setLockMode​(javax.persistence.LockModeType lockMode)
        指定者:
        setLockMode 在接口中 javax.persistence.Query
        指定者:
        setLockMode 在接口中 Query<R>
        指定者:
        setLockMode 在接口中 javax.persistence.TypedQuery<R>
      • setCacheable

        Query<R> setCacheable​(boolean cacheable)
        从接口复制的说明: Query
        Enable/disable second level query (result) caching for this query.
        指定者:
        setCacheable 在接口中 BasicQueryContract<R>
        指定者:
        setCacheable 在接口中 Query<R>
        参数:
        cacheable - Should the query results be cacheable?
        返回:
        this, for method chaining
        另请参阅:
        Query.isCacheable()
      • setCacheRegion

        Query<R> setCacheRegion​(String cacheRegion)
        从接口复制的说明: Query
        Set the name of the cache region where query results should be cached (if cached at all).
        指定者:
        setCacheRegion 在接口中 BasicQueryContract<R>
        指定者:
        setCacheRegion 在接口中 Query<R>
        参数:
        cacheRegion - the name of a query cache region, or null to indicate that the default region should be used.
        返回:
        this, for method chaining
        另请参阅:
        Query.getCacheRegion()
      • setTimeout

        Query<R> setTimeout​(int timeout)
        从接口复制的说明: Query
        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.
        指定者:
        setTimeout 在接口中 BasicQueryContract<R>
        指定者:
        setTimeout 在接口中 Query<R>
        参数:
        timeout - the timeout in seconds
        返回:
        this, for method chaining
        另请参阅:
        Query.getTimeout()
      • setLockMode

        Query<R> setLockMode​(String alias,
                             LockMode lockMode)
        从接口复制的说明: 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).
        指定者:
        setLockMode 在接口中 Query<R>
        参数:
        alias - a query alias, or "this" for a collection filter
        lockMode - The lock mode to apply.
        返回:
        this, for method chaining
        另请参阅:
        Query.getLockOptions()
      • setComment

        Query<R> setComment​(String comment)
        从接口复制的说明: Query
        Set the comment for this query.
        指定者:
        setComment 在接口中 Query<R>
        参数:
        comment - The human-readable comment
        返回:
        this, for method chaining
        另请参阅:
        Query.getComment()
      • addQueryHint

        Query<R> addQueryHint​(String hint)
        从接口复制的说明: Query
        Add a DB query hint to the SQL. These differ from JPA's QueryHint, 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.
        指定者:
        addQueryHint 在接口中 Query<R>
        参数:
        hint - The database specific query hint to add.
      • setParameterList

        <P> Query<R> setParameterList​(QueryParameter<P> parameter,
                                      Collection<P> values)
        从接口复制的说明: 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).
        指定者:
        setParameterList 在接口中 Query<R>
        参数:
        parameter - the parameter memento
        values - a collection of values to list
        返回:
        this, for method chaining
      • setParameterList

        Query<R> setParameterList​(String name,
                                  Collection values)
        从接口复制的说明: 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).
        指定者:
        setParameterList 在接口中 Query<R>
        参数:
        name - the name of the parameter
        values - a collection of values to list
        返回:
        this, for method chaining
      • setParameterList

        Query<R> setParameterList​(String name,
                                  Collection values,
                                  Type type)
        从接口复制的说明: 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).
        指定者:
        setParameterList 在接口中 Query<R>
        参数:
        name - the name of the parameter
        values - a collection of values to list
        type - the Hibernate type of the values
        返回:
        this, for method chaining
      • setParameterList

        Query<R> setParameterList​(String name,
                                  Object[] values,
                                  Type type)
        从接口复制的说明: 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).
        指定者:
        setParameterList 在接口中 Query<R>
        参数:
        name - the name of the parameter
        values - a collection of values to list
        type - the Hibernate type of the values
        返回:
        this, for method chaining
      • setParameterList

        Query<R> setParameterList​(String name,
                                  Object[] values)
        从接口复制的说明: 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).
        指定者:
        setParameterList 在接口中 Query<R>
        参数:
        name - the name of the parameter
        values - a collection of values to list
        返回:
        this, for method chaining
      • setProperties

        Query<R> setProperties​(Object bean)
        从接口复制的说明: 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.
        指定者:
        setProperties 在接口中 Query<R>
        参数:
        bean - any JavaBean or POJO
        返回:
        this, for method chaining
      • setProperties

        Query<R> setProperties​(Map bean)
        从接口复制的说明: 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.
        指定者:
        setProperties 在接口中 Query<R>
        参数:
        bean - a java.util.Map
        返回:
        this, for method chaining
      • setResultTransformer

        @Deprecated
        Query<R> setResultTransformer​(ResultTransformer transformer)
        已过时。
        (since 5.2)
        Set a strategy for handling the query results. This can be used to change "shape" of the query result.
        指定者:
        setResultTransformer 在接口中 Query<R>
        参数:
        transformer - The transformer to apply
        返回:
        this (for method chaining)
      • setParameters

        @Deprecated
        default Query<R> setParameters​(Object[] values,
                                       Type[] types)
        已过时。
        (since 5.2) Bind values individually
        Bind values and types to positional parameters. Allows binding more than one at a time; no real performance impact. The number of elements in each array should match. That is, element number-0 in types array corresponds to element-0 in the values array, etc,
        指定者:
        setParameters 在接口中 Query<R>
        参数:
        types - The types
        values - The values
        返回:
        this, for method chaining
      • getResultStream

        default Stream<R> getResultStream()
        JPA 2.2 defines the getResultStream method so to get a Stream from the JDBC ResultSet. Hibernate 5.2 already defines the stream() method, so getResultStream can delegate to it.
        指定者:
        getResultStream 在接口中 javax.persistence.Query
        指定者:
        getResultStream 在接口中 javax.persistence.TypedQuery<R>
        返回:
        The results Stream
        从以下版本开始:
        5.2.11