public class GenericJdbcRepository<T extends Model<ID>,ID extends Serializable> extends Object implements RepositoryOperations<T,ID>
RepositoryOperations,
designed for use with a SqlBuilder
that generates SQL queries to be executed in a JdbcTemplate.| Constructor and Description |
|---|
GenericJdbcRepository(DataSource dataSource,
ComplexTableDescription tableDescription,
org.springframework.jdbc.core.RowMapper<T> rowMapper)
Creates a new repository instance using the default constructor, but with a
MissingRowUnmapper
to enforce read-only functionality. |
GenericJdbcRepository(DataSource dataSource,
ComplexTableDescription tableDescription,
org.springframework.jdbc.core.RowMapper<T> rowMapper,
com.nurkiewicz.jdbcrepository.RowUnmapper<T> rowUnmapper)
Creates a new repository instance using a
DataSource to generate a new
JdbcTemplate, a ComplexTableDescription
used to create a SqlBuilder for
query generation, a RowMapper for mapping database records
to Model objects, and a RowUnmapper
for mapping model objects back to database records. |
GenericJdbcRepository(DataSource dataSource,
ComplexTableDescription tableDescription,
org.springframework.jdbc.core.RowMapper<T> rowMapper,
com.nurkiewicz.jdbcrepository.RowUnmapper<T> rowUnmapper,
Class<T> model) |
| Modifier and Type | Method and Description |
|---|---|
long |
count()
|
long |
count(Iterable<QueryCriteria> queryCriterias)
|
void |
delete(ID id)
CrudRepository.delete(ID) |
void |
delete(Iterable<? extends T> iterable)
CrudRepository.delete(Iterable) |
void |
delete(T t)
CrudRepository.delete(Object) |
void |
deleteAll()
CrudRepository.deleteAll() |
Iterable<Object> |
distinct(String field)
TODO
|
Iterable<Object> |
distinct(String field,
Iterable<QueryCriteria> queryCriterias)
TODO
|
boolean |
exists(ID id)
CrudRepository.exists(ID) |
List<T> |
find(Iterable<QueryCriteria> queryCriterias)
PagingAndSortingRepository.findAll(org.springframework.data.domain.Sort) |
org.springframework.data.domain.Page<T> |
find(Iterable<QueryCriteria> queryCriterias,
org.springframework.data.domain.Pageable pageable)
PagingAndSortingRepository.findAll(org.springframework.data.domain.Sort) |
List<T> |
find(Iterable<QueryCriteria> queryCriterias,
org.springframework.data.domain.Sort sort)
PagingAndSortingRepository.findAll(org.springframework.data.domain.Sort) |
List<T> |
findAll()
PagingAndSortingRepository.findAll(org.springframework.data.domain.Sort) |
List<T> |
findAll(Iterable<ID> iterable)
CrudRepository.findAll(Iterable) |
org.springframework.data.domain.Page<T> |
findAll(org.springframework.data.domain.Pageable pageable)
PagingAndSortingRepository.findAll(org.springframework.data.domain.Sort) |
List<T> |
findAll(org.springframework.data.domain.Sort sort)
PagingAndSortingRepository.findAll(org.springframework.data.domain.Sort) |
T |
findOne(ID id)
CrudRepository.findOne(ID) |
protected Condition |
getConditionFromQueryCriteria(QueryCriteria criteria)
Creates a
Condition instance from
a QueryCriteria search parameter for use
in SQL query generation. |
org.springframework.jdbc.core.JdbcTemplate |
getJdbcTemplate() |
Class<T> |
getModel()
Returns the model class reference.
|
org.springframework.jdbc.core.RowMapper<T> |
getRowMapper() |
com.nurkiewicz.jdbcrepository.RowUnmapper<T> |
getRowUnmapper() |
protected SqlBuilder |
getSqlBuilder()
Creates a new
SqlBuilder instance. |
ComplexTableDescription |
getTableDescription() |
protected static <ID> List<Object> |
idToObjectList(ID id)
Converts an
ID instance into a collection of objects. |
<S extends T> |
insert(Iterable<S> entities)
|
<S extends T> |
insert(S entity)
|
<S extends T> |
save(Iterable<S> iterable)
CrudRepository.save(Iterable) |
<S extends T> |
save(S s)
CrudRepository.save(Object) )} |
void |
truncateTable()
Truncates the target table, dropping all records.
|
<S extends T> |
update(Iterable<S> entities)
|
<S extends T> |
update(S entity)
|
public GenericJdbcRepository(DataSource dataSource, ComplexTableDescription tableDescription, org.springframework.jdbc.core.RowMapper<T> rowMapper, com.nurkiewicz.jdbcrepository.RowUnmapper<T> rowUnmapper)
DataSource to generate a new
JdbcTemplate, a ComplexTableDescription
used to create a SqlBuilder for
query generation, a RowMapper for mapping database records
to Model objects, and a RowUnmapper
for mapping model objects back to database records.dataSource - DataSourcetableDescription - ComplexTableDescriptionrowMapper - RowMapperrowUnmapper - RowUnmapperpublic GenericJdbcRepository(DataSource dataSource, ComplexTableDescription tableDescription, org.springframework.jdbc.core.RowMapper<T> rowMapper, com.nurkiewicz.jdbcrepository.RowUnmapper<T> rowUnmapper, Class<T> model)
public GenericJdbcRepository(DataSource dataSource, ComplexTableDescription tableDescription, org.springframework.jdbc.core.RowMapper<T> rowMapper)
MissingRowUnmapper
to enforce read-only functionality.dataSource - DataSourcetableDescription - ComplexTableDescriptionrowMapper - RowMapperprotected SqlBuilder getSqlBuilder()
SqlBuilder instance.SqlBuilderpublic T findOne(ID id)
CrudRepository.findOne(ID)findOne in interface org.springframework.data.repository.CrudRepository<T extends Model<ID>,ID extends Serializable>public boolean exists(ID id)
CrudRepository.exists(ID)exists in interface org.springframework.data.repository.CrudRepository<T extends Model<ID>,ID extends Serializable>public List<T> findAll()
PagingAndSortingRepository.findAll(org.springframework.data.domain.Sort)findAll in interface org.springframework.data.repository.CrudRepository<T extends Model<ID>,ID extends Serializable>public List<T> findAll(org.springframework.data.domain.Sort sort)
PagingAndSortingRepository.findAll(org.springframework.data.domain.Sort)findAll in interface org.springframework.data.repository.PagingAndSortingRepository<T extends Model<ID>,ID extends Serializable>public org.springframework.data.domain.Page<T> findAll(org.springframework.data.domain.Pageable pageable)
PagingAndSortingRepository.findAll(org.springframework.data.domain.Sort)findAll in interface org.springframework.data.repository.PagingAndSortingRepository<T extends Model<ID>,ID extends Serializable>public List<T> findAll(Iterable<ID> iterable)
CrudRepository.findAll(Iterable)findAll in interface org.springframework.data.repository.CrudRepository<T extends Model<ID>,ID extends Serializable>public long count()
count in interface org.springframework.data.repository.CrudRepository<T extends Model<ID>,ID extends Serializable>public List<T> find(Iterable<QueryCriteria> queryCriterias)
PagingAndSortingRepository.findAll(org.springframework.data.domain.Sort)find in interface RepositoryOperations<T extends Model<ID>,ID extends Serializable>public List<T> find(Iterable<QueryCriteria> queryCriterias, org.springframework.data.domain.Sort sort)
PagingAndSortingRepository.findAll(org.springframework.data.domain.Sort)find in interface RepositoryOperations<T extends Model<ID>,ID extends Serializable>public org.springframework.data.domain.Page<T> find(Iterable<QueryCriteria> queryCriterias, org.springframework.data.domain.Pageable pageable)
PagingAndSortingRepository.findAll(org.springframework.data.domain.Sort)find in interface RepositoryOperations<T extends Model<ID>,ID extends Serializable>public long count(Iterable<QueryCriteria> queryCriterias)
count in interface RepositoryOperations<T extends Model<ID>,ID extends Serializable>public Iterable<Object> distinct(String field)
distinct in interface RepositoryOperations<T extends Model<ID>,ID extends Serializable>public Iterable<Object> distinct(String field, Iterable<QueryCriteria> queryCriterias)
distinct in interface RepositoryOperations<T extends Model<ID>,ID extends Serializable>public <S extends T> S insert(S entity)
insert in interface RepositoryOperations<T extends Model<ID>,ID extends Serializable>public <S extends T> List<S> insert(Iterable<S> entities)
insert in interface RepositoryOperations<T extends Model<ID>,ID extends Serializable>public <S extends T> S update(S entity)
update in interface RepositoryOperations<T extends Model<ID>,ID extends Serializable>public <S extends T> List<S> update(Iterable<S> entities)
update in interface RepositoryOperations<T extends Model<ID>,ID extends Serializable>public <S extends T> List<S> save(Iterable<S> iterable)
CrudRepository.save(Iterable)save in interface org.springframework.data.repository.CrudRepository<T extends Model<ID>,ID extends Serializable>public <S extends T> S save(S s)
CrudRepository.save(Object) )}save in interface org.springframework.data.repository.CrudRepository<T extends Model<ID>,ID extends Serializable>public void delete(Iterable<? extends T> iterable)
CrudRepository.delete(Iterable)delete in interface org.springframework.data.repository.CrudRepository<T extends Model<ID>,ID extends Serializable>public void delete(T t)
CrudRepository.delete(Object)delete in interface org.springframework.data.repository.CrudRepository<T extends Model<ID>,ID extends Serializable>public void delete(ID id)
CrudRepository.delete(ID)delete in interface org.springframework.data.repository.CrudRepository<T extends Model<ID>,ID extends Serializable>public void deleteAll()
CrudRepository.deleteAll()deleteAll in interface org.springframework.data.repository.CrudRepository<T extends Model<ID>,ID extends Serializable>public void truncateTable()
protected static <ID> List<Object> idToObjectList(ID id)
ID instance into a collection of objects.id - primary key ID objectprotected Condition getConditionFromQueryCriteria(QueryCriteria criteria)
Condition instance from
a QueryCriteria search parameter for use
in SQL query generation.criteria - QueryCriteriaConditionpublic org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate()
public ComplexTableDescription getTableDescription()
public org.springframework.jdbc.core.RowMapper<T> getRowMapper()
public com.nurkiewicz.jdbcrepository.RowUnmapper<T> getRowUnmapper()
Copyright © 2016. All rights reserved.