public abstract class JdbcEntityPersistence<T extends EntityId,P extends Id,E extends Entity<T,P>,EB extends Entity.EntityBuilder<T,P,E,EB>,Q extends EntityQuery,QB extends EntityQuery.EntityQueryBuilder<Q,QB>,M extends EntityManager<T,P,E,EB,Q,QB,?,?,?>,R extends EntityResult<T,P,E,EB,M>,PC extends EntityPersistenceConfiguration<T,P,E,EB,M,R>> extends Object implements EntityPersistence<T,E,Q>
Modifier and Type | Field and Description |
---|---|
protected static Map<String,Object> |
EMPTY_CONTEXT |
protected static int |
MAX_QUERY_ID_COUNT |
Modifier | Constructor and Description |
---|---|
protected |
JdbcEntityPersistence(DataSource dataSource,
PrimaryKeyGenerator primaryKeyGenerator,
TimeProvider timeProvider,
PC configuration,
boolean isHierarchyValuesProfileActive,
boolean isDelayModificationUpdateQuery) |
Modifier and Type | Method and Description |
---|---|
protected Set<String> |
collectEntityIds(String id,
String path,
boolean includeIdsOnPath) |
long |
count(Q query)
Returns how many entities match the given query.
|
GlobalId |
createUniqueGlobalId(E entity)
Returns a unique global id.
|
T |
createUniqueId(E entity)
Returns a unique id with the next available primary key that can be used to persist an entity.
|
void |
delete(T id)
Deletes the entity with the given id.
|
E |
getByExternalId(T externalId)
Retrieves the entity with the given external id.
|
E |
getByGlobalId(GlobalId globalId,
TenantId tenantId)
Retrieves the entity with the given global id and tenant id.
|
E |
getById(T id)
Retrieves the entity with the given id.
|
protected PC |
getConfiguration() |
protected ConverterProvider |
getConverterProvider() |
protected JdbcPersistence |
getJdbcPersistence() |
protected M |
getManager() |
protected String |
getMappingId(String mappingKey) |
String |
getNextPrimaryKey()
Returns the next available primary key that can be used to persist an entity.
|
protected Map<String,Object> |
getQueryContext(Q query) |
protected SqlQueryRenderer |
getSqlQueryRenderer() |
TimeProvider |
getTimeProvider() |
T |
insert(E entity)
Inserts a new entity.
|
protected abstract void |
insertChildren(E entity) |
protected boolean |
isDelayModificationUpdateQuery() |
protected boolean |
isHierarchyValuesEnabled() |
List<E> |
queryList(Q query)
Retrieves all entities that match the given query.
|
E |
querySingle(Q query)
Retrieves the single entity that matches the given query.
|
protected Predicate |
restrictType(Predicate predicate) |
protected abstract void |
setChildren(List<R> results,
Set<? extends QueryHint> hints) |
protected void |
setHierarchyValuesProfileActive(boolean hierarchyValuesProfileActive) |
protected Collection<String> |
transformResultIdsToValues(Collection<? extends IdentifiableResult<E>> identifiableResults) |
protected Collection<EntityId> |
transformToEntityIds(Collection<String> entityIds) |
void |
update(E entity,
Collection<FieldChange> fieldChanges)
Updates the given entity.
|
protected abstract void |
updateChildren(E entity,
EB updatedEntityBuilder,
Collection<FieldChange> fieldChanges) |
protected abstract void |
updateEntityInDb(E entity,
EB updatedEntityBuilder,
IdentifiableParameter entityParameter,
Collection<FieldChange> fieldChanges) |
protected static final int MAX_QUERY_ID_COUNT
protected JdbcEntityPersistence(DataSource dataSource, PrimaryKeyGenerator primaryKeyGenerator, TimeProvider timeProvider, PC configuration, boolean isHierarchyValuesProfileActive, boolean isDelayModificationUpdateQuery) throws Exception
Exception
protected JdbcPersistence getJdbcPersistence()
protected ConverterProvider getConverterProvider()
protected SqlQueryRenderer getSqlQueryRenderer()
protected M getManager()
protected PC getConfiguration()
public String getNextPrimaryKey()
EntityPersistence
getNextPrimaryKey
in interface EntityPersistence<T extends EntityId,E extends Entity<T,P>,Q extends EntityQuery>
public T createUniqueId(E entity)
EntityPersistence
createUniqueId
in interface EntityPersistence<T extends EntityId,E extends Entity<T,P>,Q extends EntityQuery>
entity
- the entity for which to generate a unique idpublic GlobalId createUniqueGlobalId(E entity)
EntityPersistence
createUniqueGlobalId
in interface EntityPersistence<T extends EntityId,E extends Entity<T,P>,Q extends EntityQuery>
entity
- the entity for which to generate a unique global idpublic T insert(E entity)
EntityPersistence
insert
in interface EntityPersistence<T extends EntityId,E extends Entity<T,P>,Q extends EntityQuery>
entity
- the entity to be inserted into the entity persistenceprotected abstract void insertChildren(E entity)
public void delete(T id)
EntityPersistence
delete
in interface EntityPersistence<T extends EntityId,E extends Entity<T,P>,Q extends EntityQuery>
id
- the id of the entity to be deleted from the entity persistencepublic void update(E entity, Collection<FieldChange> fieldChanges)
EntityPersistence
update
in interface EntityPersistence<T extends EntityId,E extends Entity<T,P>,Q extends EntityQuery>
entity
- the entity to be updated in the entity persistencefieldChanges
- optional list of field changes that encapsulate the fine-grained entity changesprotected abstract void updateEntityInDb(E entity, EB updatedEntityBuilder, IdentifiableParameter entityParameter, Collection<FieldChange> fieldChanges)
protected abstract void updateChildren(E entity, EB updatedEntityBuilder, Collection<FieldChange> fieldChanges)
public E getById(T id)
EntityPersistence
getById
in interface EntityPersistence<T extends EntityId,E extends Entity<T,P>,Q extends EntityQuery>
id
- the id of the entity to be retrievedpublic E getByGlobalId(GlobalId globalId, TenantId tenantId)
EntityPersistence
getByGlobalId
in interface EntityPersistence<T extends EntityId,E extends Entity<T,P>,Q extends EntityQuery>
globalId
- the global id of the entity to be retrievedtenantId
- the tenant id for the tenant to be searched (may be TenantId.UNDEFINED if running in single-tenant mode)public E getByExternalId(T externalId)
EntityPersistence
getByExternalId
in interface EntityPersistence<T extends EntityId,E extends Entity<T,P>,Q extends EntityQuery>
externalId
- the external id of the entity to be retrievedpublic E querySingle(Q query)
EntityPersistence
querySingle
in interface EntityPersistence<T extends EntityId,E extends Entity<T,P>,Q extends EntityQuery>
query
- the query to matchpublic List<E> queryList(Q query)
EntityPersistence
queryList
in interface EntityPersistence<T extends EntityId,E extends Entity<T,P>,Q extends EntityQuery>
query
- the query to matchpublic long count(Q query)
EntityPersistence
count
in interface EntityPersistence<T extends EntityId,E extends Entity<T,P>,Q extends EntityQuery>
query
- the entity query to matchprotected Collection<String> transformResultIdsToValues(Collection<? extends IdentifiableResult<E>> identifiableResults)
protected Collection<EntityId> transformToEntityIds(Collection<String> entityIds)
protected Set<String> collectEntityIds(String id, String path, boolean includeIdsOnPath)
public TimeProvider getTimeProvider()
protected void setHierarchyValuesProfileActive(boolean hierarchyValuesProfileActive)
protected boolean isHierarchyValuesEnabled()
protected boolean isDelayModificationUpdateQuery()
Copyright © 2010 - 2018 edorasware ag. All Rights Reserved.