public interface JpaOperations
Modifier and Type | Method and Description |
---|---|
void |
delete(Object entity) |
void |
deleteInBatch(Iterable<?> entities) |
int |
executeUpdate(String updateQuery,
ParameterSource source)
Executes the given update statement and uses the given parameter source to
set the required query parameters.
|
int |
executeUpdateWithNamedQuery(String updateQuery,
ParameterSource source) |
int |
executeUpdateWithNativeQuery(String updateQuery,
ParameterSource source) |
<T> T |
find(Class<T> entityType,
Object id)
Find an Entity of given type with the given primary key type.
|
void |
flush()
Executes
EntityManager.flush() . |
List<?> |
getResultListForClass(Class<?> entityClass,
int firstResult,
int maxNumberOfReturnedObjects) |
List<?> |
getResultListForNamedQuery(String selectNamedQuery,
ParameterSource jpaQLParameterSource,
int firstResult,
int maxNumberOfResults) |
List<?> |
getResultListForNativeQuery(String selectQuery,
Class<?> entityClass,
ParameterSource jpaQLParameterSource,
int firstResult,
int maxNumberOfResults) |
List<?> |
getResultListForQuery(String query,
ParameterSource source)
Executes the provided query to return a list of results
|
List<?> |
getResultListForQuery(String query,
ParameterSource source,
int firstResult,
int maxNumberOfResults)
Executes the provided query to return a list of results.
|
Object |
getSingleResultForQuery(String query,
ParameterSource source)
Executes the provided query to return a single element
|
Object |
merge(Object entity)
The entity to be merged with the
EntityManager . |
Object |
merge(Object entity,
int flushSize,
boolean clearOnFlush)
The entity to be merged with the
EntityManager . |
void |
persist(Object entity)
Persists the entity.
|
void |
persist(Object entity,
int flushSize,
boolean clearOnFlush)
Persists the entity.
|
void delete(Object entity)
entity
- The entity to delete.void deleteInBatch(Iterable<?> entities)
entities
- The entities to delete.int executeUpdate(String updateQuery, ParameterSource source)
updateQuery
- Must Not be empty.source
- Must Not be null.int executeUpdateWithNamedQuery(String updateQuery, ParameterSource source)
updateQuery
- The update query.source
- The parameter source.int executeUpdateWithNativeQuery(String updateQuery, ParameterSource source)
updateQuery
- The update query.source
- The parameter source.<T> T find(Class<T> entityType, Object id)
T
- The type to return.entityType
- The type.id
- The object identifier.List<?> getResultListForClass(Class<?> entityClass, int firstResult, int maxNumberOfReturnedObjects)
entityClass
- The entity class.firstResult
- The index of the first result to return.maxNumberOfReturnedObjects
- The number of objects to return.List<?> getResultListForNamedQuery(String selectNamedQuery, ParameterSource jpaQLParameterSource, int firstResult, int maxNumberOfResults)
selectNamedQuery
- The select named query.jpaQLParameterSource
- The paramter source.firstResult
- The index of the first result to return.maxNumberOfResults
- The number of objects to return.List<?> getResultListForNativeQuery(String selectQuery, Class<?> entityClass, ParameterSource jpaQLParameterSource, int firstResult, int maxNumberOfResults)
selectQuery
- The select query.entityClass
- The entity class.jpaQLParameterSource
- The paramter source.firstResult
- The index of the first result to return.maxNumberOfResults
- The number of objects to return.List<?> getResultListForQuery(String query, ParameterSource source)
query
- The query.source
- the Parameter source for this query to be executed, if none then set as nullList<?> getResultListForQuery(String query, ParameterSource source, int firstResult, int maxNumberOfResults)
query
- Must not be null or emptyfirstResult
- The first result.maxNumberOfResults
- Must be a non-negative value, any negative or zero will be ignored.source
- the Parameter source for this query to be executed, if none then set null.Object getSingleResultForQuery(String query, ParameterSource source)
query
- Must not be emptysource
- the Parameter source for this query to be executed, if none then set as nullObject merge(Object entity)
EntityManager
.
The provided object can
also be an Iterable
in which case each object of the Iterable
is treated as an entity and merged with the
EntityManager
. Null
values returned while iterating over the Iterable
are ignored.entity
- Must not be null.Object merge(Object entity, int flushSize, boolean clearOnFlush)
EntityManager
.
The provided object can
also be an Iterable
in which case each object of the Iterable
is treated as an entity and merged with the
EntityManager
.
In addition the EntityManager.flush()
is called after the merge
and after each batch, as it is specified using flushSize
parameter and if
provided object is Iterable
.
clearOnFlush
parameter specifies, if the EntityManager.clear()
should be called after each EntityManager.flush()
.entity
- The entity.flushSize
- The flush size.clearOnFlush
- true to clear after flushing.void persist(Object entity)
Iterable
in which case each object of the Iterable
is treated as an entity
and persisted with the EntityManager
.
Null
values returned
while iterating over the Iterable
are ignored.entity
- Must not be nullvoid persist(Object entity, int flushSize, boolean clearOnFlush)
Iterable
in which case each object of the Iterable
is treated as an entity
and persisted with the EntityManager
.
Null
values returned
while iterating over the Iterable
are ignored.
In addition the EntityManager.flush()
is called after the persist
and after each batch, as it is specified using flushSize
parameter and if
provided object is Iterable
.
clearOnFlush
parameter specifies, if the EntityManager.clear()
should be called after each EntityManager.flush()
.entity
- The entity.flushSize
- The flush size.clearOnFlush
- true to clear after flushing.void flush()
EntityManager.flush()
.