public class MyBatisDataAccessStrategy extends Object implements DataAccessStrategy
DataAccessStrategy
implementation based on MyBatis. Each method gets mapped to a statement. The name of the
statement gets constructed as follows: The namespace is based on the class of the entity plus the suffix "Mapper".
This is then followed by the method name separated by a dot. For methods taking a PropertyPath
as argument,
the relevant entity is that of the root of the path, and the path itself gets as dot separated String appended to the
statement name. Each statement gets an instance of MyBatisContext
, which at least has the entityType set. For
methods taking a PropertyPath
the entityTyoe if the context is set to the class of the leaf type.Constructor and Description |
---|
MyBatisDataAccessStrategy(org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory) |
Modifier and Type | Method and Description |
---|---|
long |
count(Class<?> domainType) |
void |
delete(Object id,
Class<?> domainType) |
void |
delete(Object rootId,
PropertyPath propertyPath)
Deletes all entities reachable via propertyPath from the instance identified by rootId.
|
<T> void |
deleteAll(Class<T> domainType) |
<T> void |
deleteAll(PropertyPath propertyPath)
Deletes all entities reachable via propertyPath from any instance.
|
<T> boolean |
existsById(Object id,
Class<T> domainType) |
<T> Iterable<T> |
findAll(Class<T> domainType) |
<T> Iterable<T> |
findAllById(Iterable<?> ids,
Class<T> domainType) |
<T> Iterable<T> |
findAllByProperty(Object rootId,
JdbcPersistentProperty property)
Finds all entities reachable via property from the instance identified by rootId.
|
<T> T |
findById(Object id,
Class<T> domainType) |
<T> void |
insert(T instance,
Class<T> domainType,
Map<String,Object> additionalParameters) |
<S> void |
update(S instance,
Class<S> domainType) |
public MyBatisDataAccessStrategy(org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory)
public <T> void insert(T instance, Class<T> domainType, Map<String,Object> additionalParameters)
insert
in interface DataAccessStrategy
public <S> void update(S instance, Class<S> domainType)
update
in interface DataAccessStrategy
public void delete(Object id, Class<?> domainType)
delete
in interface DataAccessStrategy
public void delete(Object rootId, PropertyPath propertyPath)
DataAccessStrategy
delete
in interface DataAccessStrategy
rootId
- Id of the root object on which the propertyPath is based.propertyPath
- Leading from the root object to the entities to be deleted.public <T> void deleteAll(Class<T> domainType)
deleteAll
in interface DataAccessStrategy
public <T> void deleteAll(PropertyPath propertyPath)
DataAccessStrategy
deleteAll
in interface DataAccessStrategy
propertyPath
- Leading from the root object to the entities to be deleted.public <T> T findById(Object id, Class<T> domainType)
findById
in interface DataAccessStrategy
public <T> Iterable<T> findAll(Class<T> domainType)
findAll
in interface DataAccessStrategy
public <T> Iterable<T> findAllById(Iterable<?> ids, Class<T> domainType)
findAllById
in interface DataAccessStrategy
public <T> Iterable<T> findAllByProperty(Object rootId, JdbcPersistentProperty property)
DataAccessStrategy
findAllByProperty
in interface DataAccessStrategy
rootId
- 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)
existsById
in interface DataAccessStrategy
public long count(Class<?> domainType)
count
in interface DataAccessStrategy
Copyright © 2011–2018 Pivotal Software, Inc.. All rights reserved.