The Session represents the active interaction with a datastore.
Type Params | Return Type | Name and description |
---|---|---|
|
void |
attach(java.lang.Object o) Attaches an object the current session |
|
Transaction |
beginTransaction() Starts a transaction |
|
Transaction |
beginTransaction(org.springframework.transaction.TransactionDefinition definition) Starts a transaction |
|
void |
clear() Clears any pending changes to the datastore |
|
void |
clear(java.lang.Object o) Clear a specific object |
|
java.lang.Object |
clearSessionProperty(java.lang.String property) Clear a property in a session. |
|
boolean |
contains(java.lang.Object o) Whether the object is contained within the first level cache |
|
Query |
createQuery(java.lang.Class type) Creates a query instance for the give type |
|
void |
delete(java.lang.Iterable objects) Deletes one or many objects |
|
void |
delete(java.lang.Object obj) Deletes a single object |
|
long |
deleteAll(QueryableCriteria criteria) Deletes all objects matching the given criteria |
|
void |
disconnect() Disconnects from the datastore. |
|
void |
flush() Flushes any pending changes to the datastore |
|
java.lang.Object |
getAttribute(java.lang.Object entity, java.lang.String attributeName) Obtains an attribute for the given entity |
|
Datastore |
getDatastore() The Datastore that created this Session |
|
javax.persistence.FlushModeType |
getFlushMode() Obtains the current FlushModeType |
|
MappingContext |
getMappingContext() Obtains the MappingContext instance |
|
java.lang.Object |
getNativeInterface() @return The native interface to the datastore |
|
java.io.Serializable |
getObjectIdentifier(java.lang.Object instance) Obtains the identifier for the instance |
|
Persister |
getPersister(java.lang.Object o) The persister for the given object |
|
java.lang.Object |
getSessionProperty(java.lang.String property) Get the value of a property of the session. |
|
Transaction |
getTransaction() Obtains the current transaction instance |
|
boolean |
hasTransaction() @return Whether the current session has an active transaction |
|
java.io.Serializable |
insert(java.lang.Object o) Forces an insert |
|
boolean |
isConnected() @return true if connected to the datastore |
|
boolean |
isDirty(java.lang.Object instance) Check if the instance has been modified since loading. |
|
void |
lock(java.lang.Object o) Obtains a write lock on the given object |
<T> |
T |
lock(java.lang.Class<T> type, java.io.Serializable key) Retrieves an individual object, using a write lock to prevent loss of updates |
|
java.io.Serializable |
persist(java.lang.Object o) Stores and object and returns its key |
|
java.util.List<java.io.Serializable> |
persist(java.lang.Iterable objects) Persists several objects returning their identifiers in the order specified by the Iterable |
<T> |
T |
proxy(java.lang.Class<T> type, java.io.Serializable key) Retrieves a proxy for the given key |
|
void |
refresh(java.lang.Object o) Refreshes the given objects state |
<T> |
T |
retrieve(java.lang.Class<T> type, java.io.Serializable key) Retrieves an individual object |
|
java.util.List |
retrieveAll(java.lang.Class type, java.lang.Iterable keys) Retrieves several objects for the specified keys |
|
java.util.List |
retrieveAll(java.lang.Class type, java.io.Serializable... keys) Retrieves several objects for the specified keys |
|
void |
setAttribute(java.lang.Object entity, java.lang.String attributeName, java.lang.Object value) Associates an attribute with the given persistent entity. |
|
void |
setFlushMode(javax.persistence.FlushModeType flushMode) The flush mode, defaults to FlushModeType.AUTO |
|
java.lang.Object |
setSessionProperty(java.lang.String property, java.lang.Object value) Set a property on this session. |
|
void |
setSynchronizedWithTransaction(boolean synchronizedWithTransaction) Whether the session is synchronized with a transaction |
|
void |
unlock(java.lang.Object o) Releases a lock, if not called all locked objects should be released by disconnect() |
|
long |
updateAll(QueryableCriteria criteria, java.util.Map<java.lang.String, java.lang.Object> properties) Updates all objects matching the given criteria and property values |
Methods inherited from class | Name |
---|---|
interface QueryCreator |
createQuery, isSchemaless |
Attaches an object the current session
o
- The object to attachStarts a transaction
Starts a transaction
Clears any pending changes to the datastore
Clear a specific object
o
- The object to clearClear a property in a session.
property
- The property name.Whether the object is contained within the first level cache
true
if it iso
- The object to checkCreates a query instance for the give type
type
- The typeDeletes one or many objects
objects
- The objects to deleteDeletes a single object
obj
- The object to deleteDeletes all objects matching the given criteria
criteria
- The criteriaDisconnects from the datastore.
Flushes any pending changes to the datastore
Obtains an attribute for the given entity
entity
- The entityattributeName
- The attributeThe Datastore that created this Session
Obtains the current FlushModeType
Obtains the MappingContext instance
Obtains the identifier for the instance
instance
- The instanceThe persister for the given object
o
- The objectGet the value of a property of the session.
property
- The name of the property.Obtains the current transaction instance
Forces an insert
o
- The object
true
if connected to the datastoreCheck if the instance has been modified since loading.
true
if one or more fields have changedinstance
- the instanceObtains a write lock on the given object
o
- The object to lockRetrieves an individual object, using a write lock to prevent loss of updates
type
- The typekey
- The keyStores and object and returns its key
o
- The objectPersists several objects returning their identifiers in the order specified by the Iterable
objects
- The ObjectsRetrieves a proxy for the given key
type
- The typekey
- The keyRefreshes the given objects state
o
- The object to refreshRetrieves an individual object
type
- The typekey
- The keyRetrieves several objects for the specified keys
type
- The typekeys
- The keysRetrieves several objects for the specified keys
type
- The typekeys
- The keysAssociates an attribute with the given persistent entity. Attributes will be cleared out when the Session is closed or cleared.
entity
- The persistent instance (must be associated with this Session)attributeName
- The attribute namevalue
- The valueThe flush mode, defaults to FlushModeType.AUTO
flushMode
- The FlushModeTypeSet a property on this session. Note that properties are not cleared out when a session is cleared.
property
- The property name.value
- The property value.Whether the session is synchronized with a transaction
synchronizedWithTransaction
- True if it isReleases a lock, if not called all locked objects should be released by disconnect()
o
- The object to unlockUpdates all objects matching the given criteria and property values
criteria
- The criteriaproperties
- The properties