public class PersistenceManager extends Object
| Modifier and Type | Field and Description |
|---|---|
protected ConfigurationContext |
configContext |
protected PersistenceContextFactory |
contextFactory |
protected DaoContext |
daoContext |
protected Map<Class<?>,EntityMeta> |
entityMetaMap |
protected EntityProxifier |
proxifier |
| Modifier | Constructor and Description |
|---|---|
protected |
PersistenceManager(Map<Class<?>,EntityMeta> entityMetaMap,
PersistenceContextFactory contextFactory,
DaoContext daoContext,
ConfigurationContext configContext) |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
find(Class<T> entityClass,
Object primaryKey)
Find an entity.
|
<T> T |
find(Class<T> entityClass,
Object primaryKey,
ConsistencyLevel readLevel)
Find an entity with the given Consistency Level for read
|
protected ConfigurationContext |
getConfigContext() |
protected Map<Class<?>,EntityMeta> |
getEntityMetaMap() |
com.datastax.driver.core.Session |
getNativeSession() |
<T> T |
getProxy(Class<T> entityClass,
Object primaryKey)
Create a proxy for the entity.
|
<T> T |
getProxy(Class<T> entityClass,
Object primaryKey,
ConsistencyLevel readLevel)
Create a proxy for the entity.
|
<T> TypedQueryBuilder<T> |
indexedQuery(Class<T> entityClass,
IndexCondition indexCondition)
Return a CQL typed query builder
All found entities will be in 'managed' state
|
<T> List<T> |
initAndRemoveProxy(List<T> entities)
Shorthand for manager.removeProxy(manager.initialize(List
|
<T> Set<T> |
initAndRemoveProxy(Set<T> entities)
Shorthand for manager.removeProxy(manager.initialize(Set
|
<T> T |
initAndRemoveProxy(T entity)
Shorthand for manager.removeProxy(manager.initialize(T entity))
|
<T> List<T> |
initialize(List<T> entities)
Initialize all lazy fields of a list of 'managed' entities, except
WideMap/Counter fields.
|
<T> Set<T> |
initialize(Set<T> entities)
Initialize all lazy fields of a set of 'managed' entities, except
WideMap/Counter fields.
|
<T> T |
initialize(T entity)
Initialize all lazy fields of a 'managed' entity, except WideMap/Counter
fields.
|
protected PersistenceContext |
initPersistenceContext(Class<?> entityClass,
Object primaryKey,
Options options) |
protected PersistenceContext |
initPersistenceContext(Object entity,
Options options) |
NativeQueryBuilder |
nativeQuery(String queryString,
Object... boundValues)
Return a CQL native query builder
|
<T> T |
persist(T entity)
Persist an entity.
|
<T> T |
persist(T entity,
Options options)
Persist an entity with the given options.
|
<T> TypedQueryBuilder<T> |
rawTypedQuery(Class<T> entityClass,
String queryString,
Object... boundValues)
Return a CQL typed query builder
All found entities will be returned as raw entities and not 'managed' by
Achilles
|
void |
refresh(Object entity)
Refresh an entity.
|
void |
refresh(Object entity,
ConsistencyLevel readLevel)
Refresh an entity with the given Consistency Level for read.
|
void |
remove(Object entity)
Remove an entity.
|
void |
remove(Object entity,
Options options)
Remove an entity with the given Consistency Level for write.
|
void |
removeById(Class<?> entityClass,
Object primaryKey)
Remove an entity by its id.
|
void |
removeById(Class<?> entityClass,
Object primaryKey,
ConsistencyLevel writeLevel)
Remove an entity by its id with the given Consistency Level for write.
|
<T> List<T> |
removeProxy(List<T> proxies)
Remove the proxy of a list of 'managed' entities and return the underlying "raw" entities
See
removeProxy(T) |
<T> T |
removeProxy(T proxy)
Remove the proxy of a 'managed' entity and return the underlying "raw" entity
If the argument is not a proxy objet, return itself
Else, return the target object behind the proxy |
protected void |
setConfigContext(ConfigurationContext configContext) |
protected void |
setEntityMetaMap(Map<Class<?>,EntityMeta> entityMetaMap) |
<T> SliceQueryBuilder<T> |
sliceQuery(Class<T> entityClass) |
<T> TypedQueryBuilder<T> |
typedQuery(Class<T> entityClass,
String queryString,
Object... boundValues)
Return a CQL typed query builder
All found entities will be in 'managed' state
|
<T> Set<T> |
unwrap(Set<T> proxies)
Remove the proxy of a set of 'managed' entities return the underlying "raw" entities
See
removeProxy(T) |
void |
update(Object entity)
Update a "managed" entity
|
void |
update(Object entity,
Options options)
Update a "managed" entity
|
protected Map<Class<?>,EntityMeta> entityMetaMap
protected ConfigurationContext configContext
protected PersistenceContextFactory contextFactory
protected EntityProxifier proxifier
protected DaoContext daoContext
protected PersistenceManager(Map<Class<?>,EntityMeta> entityMetaMap, PersistenceContextFactory contextFactory, DaoContext daoContext, ConfigurationContext configContext)
public <T> T persist(T entity)
entity - Entity to be persistedpublic <T> T persist(T entity,
Options options)
entity - Entity to be persistedoptions - options for consistency level, ttl and timestamppublic void update(Object entity)
entity - Managed entity to be updatedpublic void update(Object entity, Options options)
entity - Managed entity to be updatedoptions - options for consistency level, ttl and timestamppublic void remove(Object entity)
entity - Entity to be removedpublic void removeById(Class<?> entityClass, Object primaryKey)
entityClass - Entity classprimaryKey - Primary keypublic void remove(Object entity, Options options)
entity - Entity to be removedoptions - options for consistency level and timestamppublic void removeById(Class<?> entityClass, Object primaryKey, ConsistencyLevel writeLevel)
entityClass - Entity classprimaryKey - Primary keypublic <T> T find(Class<T> entityClass, Object primaryKey)
entityClass - Entity typeprimaryKey - Primary key (Cassandra row key) of the entity to loadpublic <T> T find(Class<T> entityClass, Object primaryKey, ConsistencyLevel readLevel)
entityClass - Entity typeprimaryKey - Primary key (Cassandra row key) of the entity to loadreadLevel - Consistency Level for readpublic <T> T getProxy(Class<T> entityClass, Object primaryKey)
entityClass - Entity typeprimaryKey - Primary key (Cassandra row key) of the entity to initializepublic <T> T getProxy(Class<T> entityClass, Object primaryKey, ConsistencyLevel readLevel)
entityClass - Entity typeprimaryKey - Primary key (Cassandra row key) of the entity to initializereadLevel - Consistency Level for readpublic void refresh(Object entity) throws AchillesStaleObjectStateException
entity - Entity to be refreshedAchillesStaleObjectStateExceptionpublic void refresh(Object entity, ConsistencyLevel readLevel) throws AchillesStaleObjectStateException
entity - Entity to be refreshedreadLevel - Consistency Level for readAchillesStaleObjectStateExceptionpublic <T> T initialize(T entity)
public <T> Set<T> initialize(Set<T> entities)
public <T> List<T> initialize(List<T> entities)
public <T> T initAndRemoveProxy(T entity)
public <T> Set<T> initAndRemoveProxy(Set<T> entities)
public <T> List<T> initAndRemoveProxy(List<T> entities)
public <T> T removeProxy(T proxy)
proxy - public <T> List<T> removeProxy(List<T> proxies)
removeProxy(T)proxies - list of proxified entitypublic <T> Set<T> unwrap(Set<T> proxies)
removeProxy(T)proxies - set of proxified entitiespublic <T> SliceQueryBuilder<T> sliceQuery(Class<T> entityClass)
public NativeQueryBuilder nativeQuery(String queryString, Object... boundValues)
queryString - native CQL query string, including limit, ttl and consistency
optionsboundValues - values to be bind to the parameterized query, if anypublic <T> TypedQueryBuilder<T> typedQuery(Class<T> entityClass, String queryString, Object... boundValues)
entityClass - type of entity to be returnedqueryString - native CQL query string, including limit, ttl and consistency
optionsboundValues - values to be bind to the parameterized query, if anypublic <T> TypedQueryBuilder<T> indexedQuery(Class<T> entityClass, IndexCondition indexCondition)
entityClass - type of entity to be returnedindexCondition - index conditionpublic <T> TypedQueryBuilder<T> rawTypedQuery(Class<T> entityClass, String queryString, Object... boundValues)
entityClass - type of entity to be returnedqueryString - native CQL query string, including limit, ttl and consistency
optionsboundValues - values to be bind to the parameterized query, if anyprotected PersistenceContext initPersistenceContext(Class<?> entityClass, Object primaryKey, Options options)
protected PersistenceContext initPersistenceContext(Object entity, Options options)
public com.datastax.driver.core.Session getNativeSession()
protected Map<Class<?>,EntityMeta> getEntityMetaMap()
protected ConfigurationContext getConfigContext()
protected void setEntityMetaMap(Map<Class<?>,EntityMeta> entityMetaMap)
protected void setConfigContext(ConfigurationContext configContext)
Copyright © 2012-2014. All Rights Reserved.