|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.datastore.core.AbstractSession<N>
public abstract class AbstractSession<N>
Abstract implementation of the Session
interface that uses
a list of Persister
instances
to save, update and delete instances
Field Summary | |
---|---|
protected Map<Object,Map<String,Object>> |
attributes
|
protected Map<Class,Map<Serializable,Object>> |
firstLevelCache
|
protected List<EntityInterceptor> |
interceptors
|
protected ConcurrentLinkedQueue |
lockedObjects
|
protected Map<Object,Serializable> |
objectToKey
|
protected Collection<Runnable> |
pendingDeletes
|
protected Collection<Runnable> |
pendingInserts
|
protected Collection<Runnable> |
pendingUpdates
|
protected Map<Class,Persister> |
persisters
|
Constructor Summary | |
---|---|
AbstractSession(Datastore datastore,
MappingContext mappingContext)
|
Method Summary | |
---|---|
void |
addEntityInterceptor(EntityInterceptor interceptor)
Adds an EntityInterceptor |
void |
attach(Object o)
Attaches an object the current session |
Transaction |
beginTransaction()
Starts a transaction |
protected abstract Transaction |
beginTransactionInternal()
|
protected void |
cacheObject(Serializable identifier,
Object o)
|
void |
clear()
Clears any pending changes to the datastore |
void |
clear(Object o)
Clear a specific object |
boolean |
contains(Object o)
Whether the object is contained within the first level cache |
protected abstract Persister |
createPersister(Class cls,
MappingContext mappingContext)
|
Query |
createQuery(Class type)
Creates a query instance for the give type |
void |
delete(Iterable objects)
Deletes one or many objects |
void |
delete(Object obj)
Deletes a single object |
void |
disconnect()
Performs clear up. |
void |
flush()
Flushes any pending changes to the datastore |
Object |
getAttribute(Object entity,
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 |
Collection<Runnable> |
getPendingDeletes()
|
Collection<Runnable> |
getPendingInserts()
|
Collection<Runnable> |
getPendingUpdates()
|
Persister |
getPersister(Object o)
The persister for the given object |
Transaction |
getTransaction()
Obtains the current transaction instance |
Object |
lock(Class type,
Serializable key)
Retrieves an individual object, using a write lock to prevent loss of updates |
void |
lock(Object o)
Obtains a write lock on the given object |
List<Serializable> |
persist(Iterable objects)
Persists several objects returning their identifiers in the order specified by the Iterable |
Serializable |
persist(Object o)
Stores and object and returns its key |
protected void |
postFlush()
|
Object |
proxy(Class type,
Serializable key)
Retrieves a proxy for the given key |
void |
refresh(Object o)
Refreshes the given objects state |
Object |
retrieve(Class type,
Serializable key)
Retrieves an individual object |
List |
retrieveAll(Class type,
Iterable keys)
Retrieves several objects for the specified keys |
List |
retrieveAll(Class type,
Serializable... keys)
Retrieves several objects for the specified keys |
void |
setAttribute(Object entity,
String attributeName,
Object value)
Associates an attribute with the given persistent entity. |
void |
setEntityInterceptors(List<EntityInterceptor> interceptors)
|
void |
setFlushMode(javax.persistence.FlushModeType flushMode)
The flush mode, defaults to FlushModeType.AUTO |
void |
unlock(Object o)
Releases a lock, if not called all locked objects should be released by Session.disconnect() |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.springframework.datastore.core.Session |
---|
getNativeInterface, isConnected |
Field Detail |
---|
protected Map<Class,Persister> persisters
protected List<EntityInterceptor> interceptors
protected ConcurrentLinkedQueue lockedObjects
protected Map<Class,Map<Serializable,Object>> firstLevelCache
protected Map<Object,Map<String,Object>> attributes
protected Map<Object,Serializable> objectToKey
protected Collection<Runnable> pendingInserts
protected Collection<Runnable> pendingUpdates
protected Collection<Runnable> pendingDeletes
Constructor Detail |
---|
public AbstractSession(Datastore datastore, MappingContext mappingContext)
Method Detail |
---|
public void setAttribute(Object entity, String attributeName, Object value)
Session
setAttribute
in interface Session
entity
- The persistent instance (must be associated with this Session)attributeName
- The attribute namevalue
- The valuepublic Object getAttribute(Object entity, String attributeName)
Session
getAttribute
in interface Session
entity
- The entityattributeName
- The attribute
public Collection<Runnable> getPendingInserts()
getPendingInserts
in interface SessionImplementor
public Collection<Runnable> getPendingUpdates()
getPendingUpdates
in interface SessionImplementor
public Collection<Runnable> getPendingDeletes()
getPendingDeletes
in interface SessionImplementor
public javax.persistence.FlushModeType getFlushMode()
Session
getFlushMode
in interface Session
public void setFlushMode(javax.persistence.FlushModeType flushMode)
Session
setFlushMode
in interface Session
flushMode
- The FlushModeTypepublic Datastore getDatastore()
Session
getDatastore
in interface Session
public void addEntityInterceptor(EntityInterceptor interceptor)
EntityInterceptorAware
EntityInterceptor
addEntityInterceptor
in interface EntityInterceptorAware
interceptor
- The interceptor to addpublic void setEntityInterceptors(List<EntityInterceptor> interceptors)
setEntityInterceptors
in interface EntityInterceptorAware
interceptors
- A list of entity interceptorspublic MappingContext getMappingContext()
Session
getMappingContext
in interface Session
public void flush()
Session
flush
in interface Session
protected void postFlush()
public void clear()
Session
clear
in interface Session
public final Persister getPersister(Object o)
Session
getPersister
in interface Session
o
- The object
protected abstract Persister createPersister(Class cls, MappingContext mappingContext)
public boolean contains(Object o)
Session
contains
in interface Session
o
- The object to check
public void clear(Object o)
Session
clear
in interface Session
o
- The object to clearpublic void attach(Object o)
Session
attach
in interface Session
o
- The object to attachprotected void cacheObject(Serializable identifier, Object o)
public Serializable persist(Object o)
Session
persist
in interface Session
o
- The object
public void refresh(Object o)
Session
refresh
in interface Session
o
- The object to refreshpublic Object retrieve(Class type, Serializable key)
Session
retrieve
in interface Session
type
- The typekey
- The key
public Object proxy(Class type, Serializable key)
Session
proxy
in interface Session
type
- The typekey
- The key
public void lock(Object o)
Session
lock
in interface Session
o
- The object to lockpublic Object lock(Class type, Serializable key)
Session
lock
in interface Session
type
- The typekey
- The key
public void unlock(Object o)
Session
Session.disconnect()
unlock
in interface Session
o
- The object to unlockpublic void delete(Object obj)
Session
delete
in interface Session
obj
- The object to deletepublic void delete(Iterable objects)
Session
delete
in interface Session
objects
- The objects to deletepublic void disconnect()
disconnect
in interface Session
public List<Serializable> persist(Iterable objects)
Session
persist
in interface Session
objects
- The Objects
public List retrieveAll(Class type, Iterable keys)
Session
retrieveAll
in interface Session
type
- The typekeys
- The keys
public List retrieveAll(Class type, Serializable... keys)
Session
retrieveAll
in interface Session
type
- The typekeys
- The keys
public Query createQuery(Class type)
Session
createQuery
in interface Session
type
- The type
public final Transaction beginTransaction()
Session
beginTransaction
in interface Session
protected abstract Transaction beginTransactionInternal()
public Transaction getTransaction()
Session
getTransaction
in interface Session
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |