|
Spring Data Jpa | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.data.jpa.repository.support.SimpleJpaRepository<T,ID>
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>
Default implementation of the CrudRepository
interface. This will offer
you a more sophisticated interface than the plain EntityManager
.
Constructor Summary | |
---|---|
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 . |
Method Summary | ||
---|---|---|
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. |
|
|
save(Iterable<S> entities)
|
|
|
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 LockModeType s to be applied to
queries. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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.Method Detail |
---|
public void setLockMetadataProvider(LockMetadataProvider lockMetadataProvider)
LockMetadataProvider
to be used to detect LockModeType
s 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)
JpaRepository
Query
. 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()
JpaRepository
deleteAllInBatch
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)
JpaSpecificationExecutor
Specification
.
findOne
in interface JpaSpecificationExecutor<T>
public List<T> findAll(Specification<T> spec)
JpaSpecificationExecutor
Specification
.
findAll
in interface JpaSpecificationExecutor<T>
public Page<T> findAll(Specification<T> spec, Pageable pageable)
JpaSpecificationExecutor
Page
of entities matching the given Specification
.
findAll
in interface JpaSpecificationExecutor<T>
public List<T> findAll(Specification<T> spec, Sort sort)
JpaSpecificationExecutor
Specification
and Sort
.
findAll
in interface JpaSpecificationExecutor<T>
public long count()
count
in interface CrudRepository<T,ID extends Serializable>
public long count(Specification<T> spec)
JpaSpecificationExecutor
Specification
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)
JpaRepository
saveAndFlush
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()
JpaRepository
flush
in interface JpaRepository<T,ID extends Serializable>
|
Spring Data Jpa | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |