org.springframework.orm.jpa
Interface JpaOperations

All Known Implementing Classes:
JpaTemplate

public interface JpaOperations

Interface that specifies a basic set of JPA operations, implemented by JpaTemplate. Not often used, but a useful option to enhance testability, as it can easily be mocked or stubbed.

Defines JpaTemplate's data access methods that mirror various EntityManager methods. Users are strongly encouraged to read the JPA EntityManager javadocs for details on the semantics of those methods.

Note that lazy loading will just work with an open JPA EntityManager, either within a managed transaction or within OpenEntityManagerInViewFilter/ OpenEntityManagerInViewInterceptor. Furthermore, some operations just make sense within transactions, for example: flush, clear.

Since:
2.0
Author:
Juergen Hoeller
See Also:
JpaTemplate, EntityManager, JpaTransactionManager, JpaDialect, OpenEntityManagerInViewFilter, OpenEntityManagerInViewInterceptor

Method Summary
 boolean contains(Object entity)
           
<T> T
execute(JpaCallback<T> action)
           
 List executeFind(JpaCallback<?> action)
           
<T> T
find(Class<T> entityClass, Object id)
           
 List find(String queryString)
           
 List find(String queryString, Object... values)
           
 List findByNamedParams(String queryString, Map<String,?> params)
           
 List findByNamedQuery(String queryName)
           
 List findByNamedQuery(String queryName, Object... values)
           
 List findByNamedQueryAndNamedParams(String queryName, Map<String,?> params)
           
 void flush()
           
<T> T
getReference(Class<T> entityClass, Object id)
           
<T> T
merge(T entity)
           
 void persist(Object entity)
           
 void refresh(Object entity)
           
 void remove(Object entity)
           
 

Method Detail

execute

<T> T execute(JpaCallback<T> action)
          throws DataAccessException
Throws:
DataAccessException

executeFind

List executeFind(JpaCallback<?> action)
                 throws DataAccessException
Throws:
DataAccessException

find

<T> T find(Class<T> entityClass,
           Object id)
       throws DataAccessException
Throws:
DataAccessException

getReference

<T> T getReference(Class<T> entityClass,
                   Object id)
               throws DataAccessException
Throws:
DataAccessException

contains

boolean contains(Object entity)
                 throws DataAccessException
Throws:
DataAccessException

refresh

void refresh(Object entity)
             throws DataAccessException
Throws:
DataAccessException

persist

void persist(Object entity)
             throws DataAccessException
Throws:
DataAccessException

merge

<T> T merge(T entity)
        throws DataAccessException
Throws:
DataAccessException

remove

void remove(Object entity)
            throws DataAccessException
Throws:
DataAccessException

flush

void flush()
           throws DataAccessException
Throws:
DataAccessException

find

List find(String queryString)
          throws DataAccessException
Throws:
DataAccessException

find

List find(String queryString,
          Object... values)
          throws DataAccessException
Throws:
DataAccessException

findByNamedParams

List findByNamedParams(String queryString,
                       Map<String,?> params)
                       throws DataAccessException
Throws:
DataAccessException

findByNamedQuery

List findByNamedQuery(String queryName)
                      throws DataAccessException
Throws:
DataAccessException

findByNamedQuery

List findByNamedQuery(String queryName,
                      Object... values)
                      throws DataAccessException
Throws:
DataAccessException

findByNamedQueryAndNamedParams

List findByNamedQueryAndNamedParams(String queryName,
                                    Map<String,?> params)
                                    throws DataAccessException
Throws:
DataAccessException