public class DefaultDataAccessStrategy extends Object implements DataAccessStrategy
DataAccessStrategy is to generate SQL statements based on meta data from the entity.| Constructor and Description |
|---|
DefaultDataAccessStrategy(SqlGeneratorSource sqlGeneratorSource,
RelationalMappingContext context,
RelationalConverter converter,
NamedParameterJdbcOperations operations)
Creates a
DefaultDataAccessStrategy which references it self for resolution of recursive data accesses. |
DefaultDataAccessStrategy(@NonNull SqlGeneratorSource sqlGeneratorSource,
@NonNull RelationalMappingContext context,
@NonNull RelationalConverter converter,
@NonNull NamedParameterJdbcOperations operations,
@NonNull DataAccessStrategy accessStrategy) |
| Modifier and Type | Method and Description |
|---|---|
long |
count(Class<?> domainType)
Counts the rows in the table representing the given domain type.
|
void |
delete(Object id,
Class<?> domainType)
deletes a single row identified by the id, from the table identified by the domainType.
|
void |
delete(Object rootId,
PersistentPropertyPath<RelationalPersistentProperty> propertyPath)
Deletes all entities reachable via propertyPath from the instance identified by rootId.
|
<T> void |
deleteAll(Class<T> domainType)
Deletes all entities of the given domain type.
|
void |
deleteAll(PersistentPropertyPath<RelationalPersistentProperty> propertyPath)
Deletes all entities reachable via propertyPath from any instance.
|
<T> boolean |
existsById(Object id,
Class<T> domainType)
returns if a row with the given id exists for the given type.
|
<T> Iterable<T> |
findAll(Class<T> domainType)
Loads all entities of the given type.
|
<T> Iterable<T> |
findAllById(Iterable<?> ids,
Class<T> domainType)
Loads all entities that match one of the ids passed as an argument.
|
<T> Iterable<T> |
findAllByProperty(Object rootId,
RelationalPersistentProperty property)
Finds all entities reachable via property from the instance identified by rootId.
|
<T> T |
findById(Object id,
Class<T> domainType)
Loads a single entity identified by type and id.
|
<T> Object |
insert(T instance,
Class<T> domainType,
Map<String,Object> additionalParameters)
Inserts a the data of a single entity.
|
<S> boolean |
update(S instance,
Class<S> domainType)
Updates the data of a single entity in the database.
|
public DefaultDataAccessStrategy(SqlGeneratorSource sqlGeneratorSource, RelationalMappingContext context, RelationalConverter converter, NamedParameterJdbcOperations operations)
DefaultDataAccessStrategy which references it self for resolution of recursive data accesses.
Only suitable if this is the only access strategy in use.public DefaultDataAccessStrategy(@NonNull
@NonNull SqlGeneratorSource sqlGeneratorSource,
@NonNull
@NonNull RelationalMappingContext context,
@NonNull
@NonNull RelationalConverter converter,
@NonNull
@NonNull NamedParameterJdbcOperations operations,
@NonNull
@NonNull DataAccessStrategy accessStrategy)
public <T> Object insert(T instance, Class<T> domainType, Map<String,Object> additionalParameters)
DataAccessStrategyinsert in interface DataAccessStrategyT - the type of the instance.instance - the instance to be stored. Must not be null.domainType - the type of the instance. Must not be null.additionalParameters - name-value pairs of additional parameters. Especially ids of parent entities that need
to get referenced are contained in this map. Must not be null.public <S> boolean update(S instance,
Class<S> domainType)
DataAccessStrategyupdate in interface DataAccessStrategyS - the type of the instance to save.instance - the instance to save. Must not be null.domainType - the type of the instance to save. Must not be null.public void delete(Object id, Class<?> domainType)
DataAccessStrategydelete in interface DataAccessStrategyid - the id of the row to be deleted. Must not be null.domainType - the type of entity to be deleted. Implicitly determines the table to operate on. Must not be
null.public void delete(Object rootId, PersistentPropertyPath<RelationalPersistentProperty> propertyPath)
DataAccessStrategydelete in interface DataAccessStrategyrootId - Id of the root object on which the propertyPath is based. Must not be null.propertyPath - Leading from the root object to the entities to be deleted. Must not be null.public <T> void deleteAll(Class<T> domainType)
DataAccessStrategydeleteAll in interface DataAccessStrategyT - type of the domain type.domainType - the domain type for which to delete all entries. Must not be null.public void deleteAll(PersistentPropertyPath<RelationalPersistentProperty> propertyPath)
DataAccessStrategydeleteAll in interface DataAccessStrategypropertyPath - Leading from the root object to the entities to be deleted. Must not be null.public long count(Class<?> domainType)
DataAccessStrategycount in interface DataAccessStrategydomainType - the domain type for which to count the elements. Must not be null.null.public <T> T findById(Object id, Class<T> domainType)
DataAccessStrategyfindById in interface DataAccessStrategyT - the type of the entity.id - the id of the entity to load. Must not be null.domainType - the domain type of the entity. Must not be null.null.public <T> Iterable<T> findAll(Class<T> domainType)
DataAccessStrategyfindAll in interface DataAccessStrategyT - the type of entities to load.domainType - the type of entities to load. Must not be null.null.public <T> Iterable<T> findAllById(Iterable<?> ids, Class<T> domainType)
DataAccessStrategyfindAllById in interface DataAccessStrategyT - type of entities to load.ids - the Ids of the entities to load. Must not be null.domainType - the type of entities to laod. Must not be null.null.public <T> Iterable<T> findAllByProperty(Object rootId, RelationalPersistentProperty property)
DataAccessStrategyfindAllByProperty in interface DataAccessStrategyrootId - Id of the root object on which the propertyPath is based.property - Leading from the root object to the entities to be found.public <T> boolean existsById(Object id, Class<T> domainType)
DataAccessStrategyexistsById in interface DataAccessStrategyT - the type of the entity.id - the id of the entity for which to check. Must not be null.domainType - the type of the entity to check for. Must not be null.true if a matching row exists, otherwise false.Copyright © 2017–2019 Pivotal Software, Inc.. All rights reserved.