Spring Data Jpa

org.springframework.data.jpa.repository.support
Class SimpleJpaRepository<T,ID extends Serializable>

java.lang.Object
  extended by org.springframework.data.repository.support.RepositorySupport<T,ID>
      extended by org.springframework.data.jpa.repository.support.JpaRepositorySupport<T,ID>
          extended by org.springframework.data.jpa.repository.support.SimpleJpaRepository<T,ID>
Type Parameters:
T - the type of the entity to handle
ID - the type of the entity's identifier
All Implemented Interfaces:
JpaRepository<T,ID>, org.springframework.data.repository.PagingAndSortingRepository<T,ID>, org.springframework.data.repository.Repository<T,ID>

@Repository
public class SimpleJpaRepository<T,ID extends Serializable>
extends JpaRepositorySupport<T,ID>

Default implementation of the Repository interface. This will offer you a more sophisticated interface than the plain EntityManager .

Author:
Oliver Gierke, Eberhard Wolff

Constructor Summary
SimpleJpaRepository(Class<T> domainClass, javax.persistence.EntityManager entityManager)
          Creates a new SimpleJpaRepository to manage objects of the given domain type.
 
Method Summary
 Long count()
           
static
<T,ID extends Serializable>
org.springframework.data.repository.Repository<T,ID>
create(Class<T> domainClass, javax.persistence.EntityManager entityManager)
          Factory method to create SimpleJpaRepository instances.
 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)
           
 List<T> findAll(Specification<T> spec)
          Returns all entities matching the given Specification.
 org.springframework.data.domain.Page<T> findAll(Specification<T> spec, org.springframework.data.domain.Pageable pageable)
          Returns a Page of entities matching the given Specification.
 T findById(ID id)
           
 T findOne(Specification<T> spec)
          Returns a single entity matching the given Specification.
 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.
 
Methods inherited from class org.springframework.data.jpa.repository.support.JpaRepositorySupport
createIsNewStrategy
 
Methods inherited from class org.springframework.data.repository.support.RepositorySupport
getDomainClass, getIsNewStrategy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleJpaRepository

public SimpleJpaRepository(Class<T> domainClass,
                           javax.persistence.EntityManager entityManager)
Creates a new SimpleJpaRepository to manage objects of the given domain type.

Parameters:
domainClass -
entityManager -
Method Detail

create

public static <T,ID extends Serializable> org.springframework.data.repository.Repository<T,ID> create(Class<T> domainClass,
                                                                                                      javax.persistence.EntityManager entityManager)
Factory method to create SimpleJpaRepository instances.

Type Parameters:
T - the type of the entity to handle
ID - the type of the entity's identifier
Parameters:
domainClass - the domain class to handle
entityManager - the EntityManager backing the repository
Returns:

delete

public void delete(T entity)

delete

public void delete(Iterable<? extends T> entities)

deleteInBatch

public void deleteInBatch(Iterable<T> entities)
Description copied from interface: JpaRepository
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.


deleteAll

public void deleteAll()

findById

public T findById(ID id)

exists

public boolean exists(ID id)

findAll

public List<T> findAll()

findAll

public List<T> findAll(org.springframework.data.domain.Sort sort)

findAll

public org.springframework.data.domain.Page<T> findAll(org.springframework.data.domain.Pageable pageable)

findOne

public T findOne(Specification<T> spec)
Description copied from interface: JpaRepository
Returns a single entity matching the given Specification.

Returns:

findAll

public List<T> findAll(Specification<T> spec)
Description copied from interface: JpaRepository
Returns all entities matching the given Specification.

Returns:

findAll

public org.springframework.data.domain.Page<T> findAll(Specification<T> spec,
                                                       org.springframework.data.domain.Pageable pageable)
Description copied from interface: JpaRepository
Returns a Page of entities matching the given Specification.

Returns:

count

public Long count()

save

public T save(T entity)

saveAndFlush

public T saveAndFlush(T entity)
Description copied from interface: JpaRepository
Saves an entity and flushes changes instantly.

Returns:
the saved entity

save

public List<T> save(Iterable<? extends T> entities)

flush

public void flush()
Description copied from interface: JpaRepository
Flushes all pending changes to the database.


Spring Data Jpa

Copyright © 2011 SpringSource. All Rights Reserved.