Spring Data Jpa

org.springframework.data.jpa.repository
Interface JpaRepository<T,ID extends Serializable>

All Superinterfaces:
org.springframework.data.repository.PagingAndSortingRepository<T,ID>, org.springframework.data.repository.Repository<T,ID>
All Known Implementing Classes:
QueryDslJpaRepository, SimpleJpaRepository

@Transactional(readOnly=true)
public interface JpaRepository<T,ID extends Serializable>
extends org.springframework.data.repository.PagingAndSortingRepository<T,ID>

JPA specific extension of Repository. Redeclares methods from Repository and PagingAndSortingRepository to apply transaction configuration to those. We need to do this to allow specific extensions of the interface to override transaction configuration. If we'd annotated the implementation this configuration would always enjoy precedence over the configuration applied on an interface.

Author:
Oliver Gierke

Method Summary
 Long count()
           
 void delete(Iterable<? extends T> entities)
           
 void delete(T entity)
           
 void deleteAll()
           
 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()
           
 org.springframework.data.domain.Page<T> findAll(org.springframework.data.domain.Pageable pageable)
           
 List<T> findAll(org.springframework.data.domain.Sort sort)
           
 T findOne(ID id)
           
 void flush()
          Flushes all pending changes to the database.
 List<T> save(Iterable<? extends T> entities)
           
 T save(T entity)
           
 T saveAndFlush(T entity)
          Saves an entity and flushes changes instantly.
 

Method Detail

save

@Transactional
T save(T entity)
Specified by:
save in interface org.springframework.data.repository.Repository<T,ID extends Serializable>

save

@Transactional
List<T> save(Iterable<? extends T> entities)
Specified by:
save in interface org.springframework.data.repository.Repository<T,ID extends Serializable>

findOne

T findOne(ID id)
Specified by:
findOne in interface org.springframework.data.repository.Repository<T,ID extends Serializable>

exists

boolean exists(ID id)
Specified by:
exists in interface org.springframework.data.repository.Repository<T,ID extends Serializable>

findAll

List<T> findAll()
Specified by:
findAll in interface org.springframework.data.repository.Repository<T,ID extends Serializable>

count

Long count()
Specified by:
count in interface org.springframework.data.repository.Repository<T,ID extends Serializable>

delete

@Transactional
void delete(T entity)
Specified by:
delete in interface org.springframework.data.repository.Repository<T,ID extends Serializable>

delete

@Transactional
void delete(Iterable<? extends T> entities)
Specified by:
delete in interface org.springframework.data.repository.Repository<T,ID extends Serializable>

deleteAll

@Transactional
void deleteAll()
Specified by:
deleteAll in interface org.springframework.data.repository.Repository<T,ID extends Serializable>

findAll

List<T> findAll(org.springframework.data.domain.Sort sort)
Specified by:
findAll in interface org.springframework.data.repository.PagingAndSortingRepository<T,ID extends Serializable>

findAll

org.springframework.data.domain.Page<T> findAll(org.springframework.data.domain.Pageable pageable)
Specified by:
findAll in interface org.springframework.data.repository.PagingAndSortingRepository<T,ID extends Serializable>

flush

@Transactional
void flush()
Flushes all pending changes to the database.


saveAndFlush

@Transactional
T saveAndFlush(T entity)
Saves an entity and flushes changes instantly.

Parameters:
entity -
Returns:
the saved entity

deleteInBatch

@Transactional
void deleteInBatch(Iterable<T> entities)
Deletes the given entities in a batch which means it will create a single Query. Assume that we will clear the EntityManager after the call.

Parameters:
entities -

Spring Data Jpa

Copyright © 2011 SpringSource. All Rights Reserved.