|
|||||||||
| 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 Sessionentity - The persistent instance (must be associated with this Session)attributeName - The attribute namevalue - The value
public Object getAttribute(Object entity,
String attributeName)
Session
getAttribute in interface Sessionentity - The entityattributeName - The attribute
public Collection<Runnable> getPendingInserts()
getPendingInserts in interface SessionImplementorpublic Collection<Runnable> getPendingUpdates()
getPendingUpdates in interface SessionImplementorpublic Collection<Runnable> getPendingDeletes()
getPendingDeletes in interface SessionImplementorpublic javax.persistence.FlushModeType getFlushMode()
Session
getFlushMode in interface Sessionpublic void setFlushMode(javax.persistence.FlushModeType flushMode)
Session
setFlushMode in interface SessionflushMode - The FlushModeTypepublic Datastore getDatastore()
Session
getDatastore in interface Sessionpublic void addEntityInterceptor(EntityInterceptor interceptor)
EntityInterceptorAwareEntityInterceptor
addEntityInterceptor in interface EntityInterceptorAwareinterceptor - The interceptor to addpublic void setEntityInterceptors(List<EntityInterceptor> interceptors)
setEntityInterceptors in interface EntityInterceptorAwareinterceptors - A list of entity interceptorspublic MappingContext getMappingContext()
Session
getMappingContext in interface Sessionpublic void flush()
Session
flush in interface Sessionprotected void postFlush()
public void clear()
Session
clear in interface Sessionpublic final Persister getPersister(Object o)
Session
getPersister in interface Sessiono - The object
protected abstract Persister createPersister(Class cls,
MappingContext mappingContext)
public boolean contains(Object o)
Session
contains in interface Sessiono - The object to check
public void clear(Object o)
Session
clear in interface Sessiono - The object to clearpublic void attach(Object o)
Session
attach in interface Sessiono - The object to attach
protected void cacheObject(Serializable identifier,
Object o)
public Serializable persist(Object o)
Session
persist in interface Sessiono - The object
public void refresh(Object o)
Session
refresh in interface Sessiono - The object to refresh
public Object retrieve(Class type,
Serializable key)
Session
retrieve in interface Sessiontype - The typekey - The key
public Object proxy(Class type,
Serializable key)
Session
proxy in interface Sessiontype - The typekey - The key
public void lock(Object o)
Session
lock in interface Sessiono - The object to lock
public Object lock(Class type,
Serializable key)
Session
lock in interface Sessiontype - The typekey - The key
public void unlock(Object o)
SessionSession.disconnect()
unlock in interface Sessiono - The object to unlockpublic void delete(Object obj)
Session
delete in interface Sessionobj - The object to deletepublic void delete(Iterable objects)
Session
delete in interface Sessionobjects - The objects to deletepublic void disconnect()
disconnect in interface Sessionpublic List<Serializable> persist(Iterable objects)
Session
persist in interface Sessionobjects - The Objects
public List retrieveAll(Class type,
Iterable keys)
Session
retrieveAll in interface Sessiontype - The typekeys - The keys
public List retrieveAll(Class type,
Serializable... keys)
Session
retrieveAll in interface Sessiontype - The typekeys - The keys
public Query createQuery(Class type)
Session
createQuery in interface Sessiontype - The type
public final Transaction beginTransaction()
Session
beginTransaction in interface Sessionprotected 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 | ||||||||