Top Description Methods
org.hibernate

public Interface BasicQueryContract<T extends org.hibernate.BasicQueryContract>

Known Direct Subinterfaces
org.hibernate.procedure.ProcedureCall, org.hibernate.query.CommonQueryContract
Annotations
@Deprecated
Imports
org.hibernate.query.CommonQueryContract, org.hibernate.type.Type

Deprecated

(since 5.2) use CommonQueryContract instead.

Defines the aspects of query definition that apply to all forms of querying.
Author
Steve Ebersole

Method Summary

Modifier and TypeMethod and Description
public CacheMode

Returns:

The query CacheMode.
getCacheMode
()

Obtain the CacheMode in effect for this query.

public String

Returns:

The specified cache region name into which query results should be placed; null indicates the default region.
getCacheRegion
()

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 isCacheable() for more information).

public Integer

Returns:

The timeout in seconds
getFetchSize
()

Obtain the JDBC fetch size hint in effect for this query.

public FlushMode

Returns:

The query FlushMode.
getHibernateFlushMode
()

Obtain the FlushMode in effect for this query.

public Type[]

Returns:

an array of types
getReturnTypes
()

Deprecated (since 5.2) with no replacement; to be removed in 6.0
Return the Hibernate types of the query results.
public Integer

Returns:

The timeout in seconds
getTimeout
()

Obtain the query timeout in seconds.

public boolean

Returns:

true if the query results are eligible for caching, false otherwise.
isCacheable
()

Are the results of this query eligible for second level query caching?

public boolean

Returns:

true if the entities and proxies loaded by the query will be put in read-only mode; false otherwise (they will be modifiable)
isReadOnly
()

Should entities and proxies loaded by this Query be put in read-only mode?

public T

Returns:

this, for method chaining
setCacheable
(boolean
Should the query results be cacheable?
cacheable
)

Enable/disable second level query (result) caching for this query.

public T

Returns:

this, for method chaining
setCacheMode
(CacheMode
The new CacheMode to use.
cacheMode
)

(Re)set the current CacheMode in effect for this query.

public T

Returns:

this, for method chaining
setCacheRegion
(String
the name of a query cache region, or null to indicate that the default region should be used.
cacheRegion
)

Set the name of the cache region where query results should be cached (if cached at all).

public T

Returns:

this, for method chaining
setFetchSize
(int
the fetch size hint
fetchSize
)

Sets a JDBC fetch size hint for the query.

public default BasicQueryContract<T extends BasicQueryContract>

Returns:

this, for method chaining
setFlushMode
(FlushMode
The new FlushMode to use.
flushMode
)

Deprecated (since 5.2) use setHibernateFlushMode instead
(Re)set the current FlushMode in effect for this query.
public T

Returns:

this, for method chaining
setHibernateFlushMode
(FlushMode
The new FlushMode to use.
flushMode
)

(Re)set the current FlushMode in effect for this query.

public T

Returns:

this, for method chaining
setReadOnly
(boolean
true indicates that entities and proxies loaded by the query are to be put in read-only mode; false indicates that entities and proxies loaded by the query will be put in modifiable mode
readOnly
)

Set the read-only/modifiable mode for entities and proxies loaded by this Query.

public T

Returns:

this, for method chaining
setTimeout
(int
the timeout in seconds
timeout
)

Set the query timeout in seconds.

Method Detail

getCacheModeback to summary
public CacheMode getCacheMode()

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.

Returns:CacheMode

The query CacheMode.

See Also
Session#getCacheMode(), CacheMode
getCacheRegionback to summary
public String getCacheRegion()

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 isCacheable() for more information). null indicates that the default region should be used.

Returns:String

The specified cache region name into which query results should be placed; null indicates the default region.

getFetchSizeback to summary
public Integer getFetchSize()

Obtain the JDBC fetch size hint in effect for this query. This value is eventually passed along to the JDBC query via java.sql.Statement#setFetchSize(int). As defined by 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.

Returns:Integer

The timeout in seconds

See Also
java.sql.Statement#getFetchSize(), java.sql.Statement#setFetchSize(int)
getHibernateFlushModeback to summary
public FlushMode getHibernateFlushMode()

Obtain the FlushMode in effect for this query. By default, the query inherits the FlushMode of the Session from which it originates.

Returns:FlushMode

The query FlushMode.

See Also
Session#getFlushMode(), FlushMode
getReturnTypesback to summary
public Type[] getReturnTypes()

Deprecated

(since 5.2) with no replacement; to be removed in 6.0

Return the Hibernate types of the query results.

Returns:Type[]

an array of types

Annotations
@Deprecated
getTimeoutback to summary
public Integer getTimeout()

Obtain the query timeout in seconds. This value is eventually passed along to the JDBC query via java.sql.Statement#setQueryTimeout(int). Zero indicates no timeout.

Returns:Integer

The timeout in seconds

See Also
java.sql.Statement#getQueryTimeout(), java.sql.Statement#setQueryTimeout(int)
isCacheableback to summary
public boolean isCacheable()

Are the results of this query eligible for second level query caching? This is different than second level caching of any returned entities and collections.

Note

the query being "eligible" for caching does not necessarily mean its results will be cached. Second level query caching still has to be enabled on the SessionFactory for this to happen. Usually that is controlled by the hibernate.cache.use_query_cache configuration setting.

Returns:boolean

true if the query results are eligible for caching, false otherwise.

See Also
org.hibernate.cfg.AvailableSettings#USE_QUERY_CACHE
isReadOnlyback to summary
public boolean isReadOnly()

Should entities and proxies loaded by this Query be put in read-only mode? If the read-only/modifiable setting was not initialized, then the default read-only/modifiable setting for the persistence context is returned instead.

Returns:boolean

true if the entities and proxies loaded by the query will be put in read-only mode; false otherwise (they will be modifiable)

See Also
setReadOnly(boolean), The read-only/modifiable setting has no impact on entities/proxies returned by the query that existed in the session before the query was executed.
setCacheableback to summary
public T setCacheable(boolean cacheable)

Enable/disable second level query (result) caching for this query.

Parameters
cacheable:boolean

Should the query results be cacheable?

Returns:T

this, for method chaining

See Also
isCacheable
setCacheModeback to summary
public T setCacheMode(CacheMode cacheMode)

(Re)set the current CacheMode in effect for this query.

Parameters
cacheMode:CacheMode

The new CacheMode to use.

Returns:T

this, for method chaining

See Also
getCacheMode()
setCacheRegionback to summary
public T setCacheRegion(String cacheRegion)

Set the name of the cache region where query results should be cached (if cached at all).

Parameters
cacheRegion:String

the name of a query cache region, or null to indicate that the default region should be used.

Returns:T

this, for method chaining

See Also
getCacheRegion()
setFetchSizeback to summary
public T setFetchSize(int fetchSize)

Sets a JDBC fetch size hint for the query.

Parameters
fetchSize:int

the fetch size hint

Returns:T

this, for method chaining

See Also
getFetchSize()
setFlushModeback to summary
public default BasicQueryContract<T extends BasicQueryContract> setFlushMode(FlushMode flushMode)

Deprecated

(since 5.2) use setHibernateFlushMode instead

(Re)set the current FlushMode in effect for this query.

Parameters
flushMode:FlushMode

The new FlushMode to use.

Returns:BasicQueryContract<T extends BasicQueryContract>

this, for method chaining

Annotations
@Deprecated
See Also
getHibernateFlushMode()
setHibernateFlushModeback to summary
public T setHibernateFlushMode(FlushMode flushMode)

(Re)set the current FlushMode in effect for this query.

Parameters
flushMode:FlushMode

The new FlushMode to use.

Returns:T

this, for method chaining

See Also
getHibernateFlushMode()
setReadOnlyback to summary
public T setReadOnly(boolean readOnly)

Set the read-only/modifiable mode for entities and proxies loaded by this Query. This setting overrides the default setting for the persistence context.

Parameters
readOnly:boolean

true indicates that entities and proxies loaded by the query are to be put in read-only mode; false indicates that entities and proxies loaded by the query will be put in modifiable mode

Returns:T

this, for method chaining

See Also
To set the default read-only/modifiable setting used for entities and proxies that are loaded into the session:, org.hibernate.engine.spi.PersistenceContext#setDefaultReadOnly(boolean), Read-only entities are not dirty-checked and snapshots of persistent state are not maintained. Read-only entities can be modified, but changes are not persisted. When a proxy is initialized, the loaded entity will have the same read-only/modifiable setting as the uninitialized proxy has, regardless of the session's current setting. The read-only/modifiable setting has no impact on entities/proxies returned by the query that existed in the session before the query was executed.
setTimeoutback to summary
public T setTimeout(int timeout)

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.

Parameters
timeout:int

the timeout in seconds

Returns:T

this, for method chaining

See Also
getTimeout()