Interface JpaOperations
- All Known Implementing Classes:
DefaultJpaOperations
public interface JpaOperations
The Interface containing all the JpaOperations those will be executed by
the Jpa Spring Integration components.
- Since:
- 2.2
- Author:
- Amol Nayak, Gunnar Hillert, Gary Russell, Artem Bilan
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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 an Entity of given type with the given primary key type.void
flush()
ExecutesEntityManager.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) Execute 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.getSingleResultForQuery
(String query, ParameterSource source) Execute the provided query to return a single element.The entity to be merged with theEntityManager
.The entity to be merged with theEntityManager
.void
Persists the entity.void
Persists the entity.
-
Method Details
-
delete
- Parameters:
entity
- The entity to delete.
-
deleteInBatch
- Parameters:
entities
- The entities to delete.
-
executeUpdate
Executes the given update statement and uses the given parameter source to set the required query parameters.- Parameters:
updateQuery
- Must Not be empty.source
- Must Not be null.- Returns:
- The number of entities updated
-
executeUpdateWithNamedQuery
- Parameters:
updateQuery
- The update query.source
- The parameter source.- Returns:
- The number of entities updated.
-
executeUpdateWithNativeQuery
- Parameters:
updateQuery
- The update query.source
- The parameter source.- Returns:
- The number of entities updated
-
find
Find an Entity of given type with the given primary key type.- Type Parameters:
T
- The type to return.- Parameters:
entityType
- The type.id
- The object identifier.- Returns:
- The entity if it exists, null otherwise.
-
getResultListForClass
List<?> getResultListForClass(Class<?> entityClass, int firstResult, int maxNumberOfReturnedObjects) - Parameters:
entityClass
- The entity class.firstResult
- The index of the first result to return.maxNumberOfReturnedObjects
- The number of objects to return.- Returns:
- The list of found entities.
-
getResultListForNamedQuery
List<?> getResultListForNamedQuery(String selectNamedQuery, ParameterSource jpaQLParameterSource, int firstResult, int maxNumberOfResults) - Parameters:
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.- Returns:
- The list of found entities.
-
getResultListForNativeQuery
List<?> getResultListForNativeQuery(String selectQuery, @Nullable Class<?> entityClass, ParameterSource jpaQLParameterSource, int firstResult, int maxNumberOfResults) - Parameters:
selectQuery
- The select query.entityClass
- The entity class.jpaQLParameterSource
- The parameter source.firstResult
- The index of the first result to return.maxNumberOfResults
- The number of objects to return.- Returns:
- The list of found entities.
-
getResultListForQuery
Execute the provided query to return a list of results.- Parameters:
query
- The query.source
- the Parameter source for this query to be executed, if none then set as null- Returns:
- The list of found entities.
-
getResultListForQuery
List<?> getResultListForQuery(String query, ParameterSource source, int firstResult, int maxNumberOfResults) Executes the provided query to return a list of results.- Parameters:
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.- Returns:
- The list of found entities.
-
getSingleResultForQuery
Execute the provided query to return a single element.- Parameters:
query
- Must not be emptysource
- the Parameter source for this query to be executed, if none then set as null- Returns:
- Will always return a result. If no object was found in the database an exception is raised.
-
merge
The entity to be merged with theEntityManager
. The provided object can also be anIterable
in which case each object of theIterable
is treated as an entity and merged with theEntityManager
.Null
values returned while iterating over theIterable
are ignored.- Parameters:
entity
- Must not be null.- Returns:
- The merged managed instance of the entity.
-
merge
The entity to be merged with theEntityManager
. The provided object can also be anIterable
in which case each object of theIterable
is treated as an entity and merged with theEntityManager
. In addition theEntityManager.flush()
is called after the merge and after each batch, as it is specified usingflushSize
parameter and if provided object isIterable
.clearOnFlush
parameter specifies, if theEntityManager.clear()
should be called after eachEntityManager.flush()
.- Parameters:
entity
- The entity.flushSize
- The flush size.clearOnFlush
- true to clear after flushing.- Returns:
- The merged object.
-
persist
Persists the entity. The provided object can also be anIterable
in which case each object of theIterable
is treated as an entity and persisted with theEntityManager
.Null
values returned while iterating over theIterable
are ignored.- Parameters:
entity
- Must not be null
-
persist
Persists the entity. The provided object can also be anIterable
in which case each object of theIterable
is treated as an entity and persisted with theEntityManager
.Null
values returned while iterating over theIterable
are ignored. In addition theEntityManager.flush()
is called after the persist and after each batch, as it is specified usingflushSize
parameter and if provided object isIterable
.clearOnFlush
parameter specifies, if theEntityManager.clear()
should be called after eachEntityManager.flush()
.- Parameters:
entity
- The entity.flushSize
- The flush size.clearOnFlush
- true to clear after flushing.
-
flush
void flush()ExecutesEntityManager.flush()
.
-