Interface JpaRepository<T,ID>
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<T,
,ID> org.springframework.data.repository.ListCrudRepository<T,
,ID> org.springframework.data.repository.ListPagingAndSortingRepository<T,
,ID> org.springframework.data.repository.PagingAndSortingRepository<T,
,ID> org.springframework.data.repository.query.QueryByExampleExecutor<T>
,org.springframework.data.repository.Repository<T,
ID>
- All Known Subinterfaces:
EnversRevisionRepository<T,
,ID, N> JpaRepositoryImplementation<T,
ID>
- All Known Implementing Classes:
QuerydslJpaRepository
,SimpleJpaRepository
@NoRepositoryBean
public interface JpaRepository<T,ID>
extends org.springframework.data.repository.ListCrudRepository<T,ID>, org.springframework.data.repository.ListPagingAndSortingRepository<T,ID>, org.springframework.data.repository.query.QueryByExampleExecutor<T>
JPA specific extension of
Repository
.- Author:
- Oliver Gierke, Christoph Strobl, Mark Paluch, Sander Krabbenborg, Jesse Wouters, Greg Turnquist, Jens Schauder
-
Method Summary
Modifier and TypeMethodDescriptionvoid
deleteAllByIdInBatch
(Iterable<ID> ids) Deletes the entities identified by the given ids using a single query.void
Deletes all entities in a batch call.void
deleteAllInBatch
(Iterable<T> entities) Deletes the given entities in a batch which means it will create a single query.default void
deleteInBatch
(Iterable<T> entities) Deprecated.findAll
(org.springframework.data.domain.Example<S> example) findAll
(org.springframework.data.domain.Example<S> example, org.springframework.data.domain.Sort sort) void
flush()
Flushes all pending changes to the database.Deprecated.usegetReferenceById(ID)
instead.Deprecated.usegetReferenceById(ID)
instead.getReferenceById
(ID id) Returns a reference to the entity with the given identifier.saveAllAndFlush
(Iterable<S> entities) Saves all entities and flushes changes instantly.<S extends T>
SsaveAndFlush
(S entity) Saves an entity and flushes changes instantly.Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, save
Methods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAll
Methods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAll
Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAll
Methods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
flush
void flush()Flushes all pending changes to the database. -
saveAndFlush
Saves an entity and flushes changes instantly.- Parameters:
entity
- entity to be saved. Must not be null.- Returns:
- the saved entity
-
saveAllAndFlush
Saves all entities and flushes changes instantly.- Parameters:
entities
- entities to be saved. Must not be null.- Returns:
- the saved entities
- Since:
- 2.5
-
deleteInBatch
Deprecated.UsedeleteAllInBatch(Iterable)
instead.Deletes the given entities in a batch which means it will create a single query. This kind of operation leaves JPAs first level cache and the database out of sync. Consider flushing theEntityManager
before calling this method.- Parameters:
entities
- entities to be deleted. Must not be null.
-
deleteAllInBatch
Deletes the given entities in a batch which means it will create a single query. This kind of operation leaves JPAs first level cache and the database out of sync. Consider flushing theEntityManager
before calling this method.It will also NOT honor cascade semantics of JPA, nor will it emit JPA lifecycle events.
- Parameters:
entities
- entities to be deleted. Must not be null.- Since:
- 2.5
-
deleteAllByIdInBatch
Deletes the entities identified by the given ids using a single query. This kind of operation leaves JPAs first level cache and the database out of sync. Consider flushing theEntityManager
before calling this method.- Parameters:
ids
- the ids of the entities to be deleted. Must not be null.- Since:
- 2.5
-
deleteAllInBatch
void deleteAllInBatch()Deletes all entities in a batch call. -
getOne
Deprecated.usegetReferenceById(ID)
instead.Returns a reference to the entity with the given identifier. Depending on how the JPA persistence provider is implemented this is very likely to always return an instance and throw anEntityNotFoundException
on first access. Some of them will reject invalid identifiers immediately.- Parameters:
id
- must not be null.- Returns:
- a reference to the entity with the given identifier.
- See Also:
-
for details on when an exception is thrown.
-
getById
Deprecated.usegetReferenceById(ID)
instead.Returns a reference to the entity with the given identifier. Depending on how the JPA persistence provider is implemented this is very likely to always return an instance and throw anEntityNotFoundException
on first access. Some of them will reject invalid identifiers immediately.- Parameters:
id
- must not be null.- Returns:
- a reference to the entity with the given identifier.
- Since:
- 2.5
- See Also:
-
for details on when an exception is thrown.
-
getReferenceById
Returns a reference to the entity with the given identifier. Depending on how the JPA persistence provider is implemented this is very likely to always return an instance and throw anEntityNotFoundException
on first access. Some of them will reject invalid identifiers immediately.- Parameters:
id
- must not be null.- Returns:
- a reference to the entity with the given identifier.
- Since:
- 2.7
- See Also:
-
for details on when an exception is thrown.
-
findAll
- Specified by:
findAll
in interfaceorg.springframework.data.repository.query.QueryByExampleExecutor<T>
-
findAll
<S extends T> List<S> findAll(org.springframework.data.domain.Example<S> example, org.springframework.data.domain.Sort sort) - Specified by:
findAll
in interfaceorg.springframework.data.repository.query.QueryByExampleExecutor<T>
-
deleteAllInBatch(Iterable)
instead.