T - the type of the entity to handleID - the type of the entity's identifier@Repository @Transactional(readOnly=true) public class SimpleJpaRepository<T,ID extends Serializable> extends Object implements JpaRepository<T,ID>, JpaSpecificationExecutor<T>
CrudRepository interface. This will offer
you a more sophisticated interface than the plain EntityManager .| Constructor and Description |
|---|
SimpleJpaRepository(Class<T> domainClass,
javax.persistence.EntityManager em)
Creates a new
SimpleJpaRepository to manage objects of the given domain type. |
SimpleJpaRepository(JpaEntityInformation<T,?> entityInformation,
javax.persistence.EntityManager entityManager)
Creates a new
SimpleJpaRepository to manage objects of the given JpaEntityInformation. |
| Modifier and Type | Method and Description |
|---|---|
long |
count() |
long |
count(Specification<T> spec)
Returns the number of instances that the given
Specification will return. |
void |
delete(ID id) |
void |
delete(Iterable<? extends T> entities) |
void |
delete(T entity) |
void |
deleteAll() |
void |
deleteAllInBatch()
Deletes all entites in a batch call.
|
void |
deleteInBatch(Iterable<T> entities)
Deletes the given entities in a batch which means it will create a single
Query. |
boolean |
exists(ID id) |
List<T> |
findAll() |
List<T> |
findAll(Iterable<ID> ids) |
Page<T> |
findAll(Pageable pageable) |
List<T> |
findAll(Sort sort) |
List<T> |
findAll(Specification<T> spec)
Returns all entities matching the given
Specification. |
Page<T> |
findAll(Specification<T> spec,
Pageable pageable)
Returns a
Page of entities matching the given Specification. |
List<T> |
findAll(Specification<T> spec,
Sort sort)
Returns all entities matching the given
Specification and Sort. |
T |
findOne(ID id) |
T |
findOne(Specification<T> spec)
Returns a single entity matching the given
Specification. |
void |
flush()
Flushes all pending changes to the database.
|
<S extends T> |
save(Iterable<S> entities) |
<S extends T> |
save(S entity) |
T |
saveAndFlush(T entity)
Saves an entity and flushes changes instantly.
|
void |
setLockMetadataProvider(LockMetadataProvider lockMetadataProvider)
Configures a custom
LockMetadataProvider to be used to detect LockModeTypes to be applied to
queries. |
public SimpleJpaRepository(JpaEntityInformation<T,?> entityInformation, javax.persistence.EntityManager entityManager)
SimpleJpaRepository to manage objects of the given JpaEntityInformation.entityInformation - must not be null.entityManager - must not be null.public SimpleJpaRepository(Class<T> domainClass, javax.persistence.EntityManager em)
SimpleJpaRepository to manage objects of the given domain type.domainClass - must not be null.em - must not be null.public void setLockMetadataProvider(LockMetadataProvider lockMetadataProvider)
LockMetadataProvider to be used to detect LockModeTypes to be applied to
queries.lockMetadataProvider - @Transactional public void delete(ID id)
delete in interface CrudRepository<T,ID extends Serializable>@Transactional public void delete(T entity)
delete in interface CrudRepository<T,ID extends Serializable>@Transactional public void delete(Iterable<? extends T> entities)
delete in interface CrudRepository<T,ID extends Serializable>@Transactional public void deleteInBatch(Iterable<T> entities)
JpaRepositoryQuery. Assume that we will clear
the EntityManager after the call.deleteInBatch in interface JpaRepository<T,ID extends Serializable>@Transactional public void deleteAll()
deleteAll in interface CrudRepository<T,ID extends Serializable>@Transactional public void deleteAllInBatch()
JpaRepositorydeleteAllInBatch in interface JpaRepository<T,ID extends Serializable>public T findOne(ID id)
findOne in interface CrudRepository<T,ID extends Serializable>public boolean exists(ID id)
exists in interface CrudRepository<T,ID extends Serializable>public List<T> findAll()
findAll in interface JpaRepository<T,ID extends Serializable>findAll in interface CrudRepository<T,ID extends Serializable>public List<T> findAll(Iterable<ID> ids)
findAll in interface CrudRepository<T,ID extends Serializable>public List<T> findAll(Sort sort)
findAll in interface JpaRepository<T,ID extends Serializable>findAll in interface PagingAndSortingRepository<T,ID extends Serializable>public Page<T> findAll(Pageable pageable)
findAll in interface PagingAndSortingRepository<T,ID extends Serializable>public T findOne(Specification<T> spec)
JpaSpecificationExecutorSpecification.findOne in interface JpaSpecificationExecutor<T>public List<T> findAll(Specification<T> spec)
JpaSpecificationExecutorSpecification.findAll in interface JpaSpecificationExecutor<T>public Page<T> findAll(Specification<T> spec, Pageable pageable)
JpaSpecificationExecutorPage of entities matching the given Specification.findAll in interface JpaSpecificationExecutor<T>public List<T> findAll(Specification<T> spec, Sort sort)
JpaSpecificationExecutorSpecification and Sort.findAll in interface JpaSpecificationExecutor<T>public long count()
count in interface CrudRepository<T,ID extends Serializable>public long count(Specification<T> spec)
JpaSpecificationExecutorSpecification will return.count in interface JpaSpecificationExecutor<T>spec - the Specification to count instances for@Transactional public <S extends T> S save(S entity)
save in interface CrudRepository<T,ID extends Serializable>@Transactional public T saveAndFlush(T entity)
JpaRepositorysaveAndFlush in interface JpaRepository<T,ID extends Serializable>@Transactional public <S extends T> List<S> save(Iterable<S> entities)
save in interface JpaRepository<T,ID extends Serializable>save in interface CrudRepository<T,ID extends Serializable>@Transactional public void flush()
JpaRepositoryflush in interface JpaRepository<T,ID extends Serializable>Copyright © 2011-2013-2013 SpringSource. All Rights Reserved.