Top Description Methods
org.hibernate.query

public Interface SynchronizeableQuery

Known Direct Subinterfaces
org.hibernate.procedure.ProcedureCall, org.hibernate.query.NativeQuery
Imports
java.util.Collection, org.hibernate.MappingException

Represents the abstract notion of a query whose results are affected by the data stored in a given set of named query spaces. A query space is usually, but not always, a relational database table, in which case the name of the space is simply the table name.

Each entity type or collection is understood to store its state in one or more query spaces. Usually, the query spaces are automatically determined by the mapping, but sometimes they must be specified explicitly using @Synchronize.

Query spaces mediate the interaction between query execution and synchronization of in-memory state with the database:

Typically, query spaces are independent (non-overlapping), and Hibernate always treats them as such. Overlapping or hierarchical query spaces are in principle meaningful, but any such relationship between query spaces is the responsibility of the client.

A query space name is not always a table name. In principle, it's permitted to be any arbitrary string which uniquely identifies an abstract location where state is stored persistently. It's even possible that the data in a single table is segmented in such a way that the table is effectively the union of multiple independent query spaces.

Author
Steve Ebersole
See Also
org.hibernate.annotations.Synchronize, org.hibernate.jpa.HibernateHints#HINT_NATIVE_SPACES

Method Summary

Modifier and TypeMethod and Description
public SynchronizeableQuery

Returns:

this, for method chaining
addSynchronizedEntityClass
(Class<?>
The class of the entity.
entityClass
)

Add all query spaces associated with the entity with the given type.

public SynchronizeableQuery

Returns:

this, for method chaining
addSynchronizedEntityName
(String
The name of an entity.
entityName
)

Add all query spaces associated with the entity with the given names.

public SynchronizeableQuery

Returns:

this, for method chaining
addSynchronizedQuerySpace
(String
The name of the query space, usually the name of a database table.
querySpace
)

Add a query space.

public Collection<String>

Returns:

The list of query spaces upon which the query is synchronized.
getSynchronizedQuerySpaces
()

Obtain the list of query spaces this query is synchronized with.

Method Detail

addSynchronizedEntityClassback to summary
public SynchronizeableQuery addSynchronizedEntityClass(Class<?> entityClass) throws MappingException

Add all query spaces associated with the entity with the given type.

Same as addSynchronizedQuerySpace for all tables mapped by the given entity.

Parameters
entityClass:Class<?>

The class of the entity.

Returns:SynchronizeableQuery

this, for method chaining

Exceptions
MappingException:
Indicates the given class could not be resolved as an entity
addSynchronizedEntityNameback to summary
public SynchronizeableQuery addSynchronizedEntityName(String entityName) throws MappingException

Add all query spaces associated with the entity with the given names.

Same as addSynchronizedQuerySpace for all tables mapped by the given entity.

Parameters
entityName:String

The name of an entity.

Returns:SynchronizeableQuery

this, for method chaining

Exceptions
MappingException:
Indicates the given name could not be resolved as an entity
addSynchronizedQuerySpaceback to summary
public SynchronizeableQuery addSynchronizedQuerySpace(String querySpace)

Add a query space. The effect of this call is to:

  • force an auto-flush if any entity associated with the current session and mapped to the given query space has pending changes which have not yet been synchronized with the database, and
  • if the result set of this query is cached, mark it for invalidation when any entity mapped to the given query space is synchronized with the database in any session.
Parameters
querySpace:String

The name of the query space, usually the name of a database table.

Returns:SynchronizeableQuery

this, for method chaining

getSynchronizedQuerySpacesback to summary
public Collection<String> getSynchronizedQuerySpaces()

Obtain the list of query spaces this query is synchronized with.

Returns:Collection<String>

The list of query spaces upon which the query is synchronized.