The Session represents the active interaction with a datastore.
Type | Name and description |
---|---|
void |
attach(java.lang.Object o) Attaches an object the current session |
Transaction |
beginTransaction() Starts a transaction |
void |
clear() Clears any pending changes to the datastore |
void |
clear(java.lang.Object o) Clear a specific object |
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 |
int |
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 |
Persister |
getPersister(java.lang.Object o) The persister for the given object |
Transaction |
getTransaction() Obtains the current transaction instance |
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 |
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 |
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 |
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 |
void |
unlock(java.lang.Object o) Releases a lock, if not called all locked objects should be released by disconnect() |
int |
updateAll(QueryableCriteria criteria, java.util.Map<java.lang.String, java.lang.Object> properties) Updates all objects matching the given criteria and property values |
Attaches an object the current session
o
- The object to attachStarts a transaction
Clears any pending changes to the datastore
Clear a specific object
o
- The object to clearWhether 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
The persister for the given object
o
- The objectObtains the current transaction instance
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 FlushModeTypeReleases 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