org.springframework.datastore.engine
Class EntityPersister

java.lang.Object
  extended by org.springframework.datastore.engine.EntityPersister
All Implemented Interfaces:
EntityInterceptorAware, Persister
Direct Known Subclasses:
LockableEntityPersister

public abstract class EntityPersister
extends Object
implements Persister, EntityInterceptorAware

A Persister specificly for persisting PersistentEntity instances

Since:
1.0

Field Summary
protected  List<EntityInterceptor> interceptors
           
protected  ProxyFactory proxyFactory
           
protected  Session session
           
 
Constructor Summary
EntityPersister(MappingContext mappingContext, PersistentEntity entity, Session session)
           
 
Method Summary
 void addEntityInterceptor(EntityInterceptor interceptor)
          Adds an EntityInterceptor
protected  EntityAccess createEntityAccess(PersistentEntity persistentEntity, Object obj)
           
 void delete(Iterable objects)
          Deletes one or many objects
 void delete(Object obj)
          Deletes a single object
protected abstract  void deleteEntities(PersistentEntity persistentEntity, Iterable objects)
           
protected abstract  void deleteEntity(PersistentEntity persistentEntity, Object obj)
           
 MappingContext getMappingContext()
           
 Serializable getObjectIdentifier(Object obj)
          Obtains an objects identifer
 PersistentEntity getPersistentEntity()
           
 ProxyFactory getProxyFactory()
           
 Class getType()
          The type this persister persists
 List<Serializable> persist(Iterable objs)
          Persists a number of objects at the same time and returns their keys in the order specified by the objs parameter
 Serializable persist(Object obj)
          Persists an object returning the identifier
protected abstract  List<Serializable> persistEntities(PersistentEntity persistentEntity, Iterable objs)
           
protected abstract  Serializable persistEntity(PersistentEntity persistentEntity, Object obj)
          Persist the given persistent entity
 Object retrieve(Serializable key)
          Retrieves an object for the given context and Key
 List<Object> retrieveAll(Iterable<Serializable> keys)
          Batch retrieve several objects in one go
 List<Object> retrieveAll(Serializable[] keys)
          Batch retrieve several objects in one go
protected abstract  List<Object> retrieveAllEntities(PersistentEntity persistentEntity, Iterable<Serializable> keys)
           
protected abstract  List<Object> retrieveAllEntities(PersistentEntity persistentEntity, Serializable[] keys)
           
protected abstract  Object retrieveEntity(PersistentEntity persistentEntity, Serializable key)
          Retrieve a PersistentEntity for the given mappingContext and key
 void setEntityInterceptors(List<EntityInterceptor> interceptors)
           
 
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.engine.Persister
createQuery, proxy, refresh
 

Field Detail

interceptors

protected List<EntityInterceptor> interceptors

session

protected Session session

proxyFactory

protected ProxyFactory proxyFactory
Constructor Detail

EntityPersister

public EntityPersister(MappingContext mappingContext,
                       PersistentEntity entity,
                       Session session)
Method Detail

getProxyFactory

public ProxyFactory getProxyFactory()

addEntityInterceptor

public void addEntityInterceptor(EntityInterceptor interceptor)
Description copied from interface: EntityInterceptorAware
Adds an EntityInterceptor

Specified by:
addEntityInterceptor in interface EntityInterceptorAware
Parameters:
interceptor - The interceptor to add

setEntityInterceptors

public void setEntityInterceptors(List<EntityInterceptor> interceptors)
Specified by:
setEntityInterceptors in interface EntityInterceptorAware
Parameters:
interceptors - A list of entity interceptors

getMappingContext

public MappingContext getMappingContext()
Returns:
The MappingContext instance

getPersistentEntity

public PersistentEntity getPersistentEntity()
Returns:
The PersistentEntity instance

getType

public Class getType()
Description copied from interface: Persister
The type this persister persists

Specified by:
getType in interface Persister
Returns:
The class this persisters persists

getObjectIdentifier

public Serializable getObjectIdentifier(Object obj)
Obtains an objects identifer

Parameters:
obj - The object
Returns:
The identifier or null if it doesn't have one

persist

public final Serializable persist(Object obj)
Persists an object returning the identifier

Specified by:
persist in interface Persister
Parameters:
obj - The object to persist
Returns:
The identifer

persist

public List<Serializable> persist(Iterable objs)
Description copied from interface: Persister
Persists a number of objects at the same time and returns their keys in the order specified by the objs parameter

Specified by:
persist in interface Persister
Parameters:
objs - The objects
Returns:
A list of keys

retrieveAll

public List<Object> retrieveAll(Iterable<Serializable> keys)
Description copied from interface: Persister
Batch retrieve several objects in one go

Specified by:
retrieveAll in interface Persister
Parameters:
keys - The keys
Returns:
The objects in a list in the same order as the specified keys

retrieveAll

public List<Object> retrieveAll(Serializable[] keys)
Description copied from interface: Persister
Batch retrieve several objects in one go

Specified by:
retrieveAll in interface Persister
Parameters:
keys - The keys
Returns:
The objects in a list in the same order as the specified keys

retrieveAllEntities

protected abstract List<Object> retrieveAllEntities(PersistentEntity persistentEntity,
                                                    Serializable[] keys)

retrieveAllEntities

protected abstract List<Object> retrieveAllEntities(PersistentEntity persistentEntity,
                                                    Iterable<Serializable> keys)

persistEntities

protected abstract List<Serializable> persistEntities(PersistentEntity persistentEntity,
                                                      Iterable objs)

retrieve

public final Object retrieve(Serializable key)
Description copied from interface: Persister
Retrieves an object for the given context and Key

Specified by:
retrieve in interface Persister
Parameters:
key - The key
Returns:
The object in question

retrieveEntity

protected abstract Object retrieveEntity(PersistentEntity persistentEntity,
                                         Serializable key)
Retrieve a PersistentEntity for the given mappingContext and key

Parameters:
persistentEntity - The entity
key - The key
Returns:
The object or null if it doesn't exist

persistEntity

protected abstract Serializable persistEntity(PersistentEntity persistentEntity,
                                              Object obj)
Persist the given persistent entity

Parameters:
persistentEntity - The PersistentEntity
obj -
Returns:
The generated key

delete

public final void delete(Iterable objects)
Description copied from interface: Persister
Deletes one or many objects

Specified by:
delete in interface Persister
Parameters:
objects - The objects to delete. Must all be of the same type or an exception will be thrown.

delete

public void delete(Object obj)
Description copied from interface: Persister
Deletes a single object

Specified by:
delete in interface Persister
Parameters:
obj - The object

deleteEntity

protected abstract void deleteEntity(PersistentEntity persistentEntity,
                                     Object obj)

deleteEntities

protected abstract void deleteEntities(PersistentEntity persistentEntity,
                                       Iterable objects)

createEntityAccess

protected EntityAccess createEntityAccess(PersistentEntity persistentEntity,
                                          Object obj)