|
Spring Integration | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.integration.jpa.core.JpaExecutor
public class JpaExecutor
Executes Jpa Operations that produce payload objects from the result of the provided:
Message
payload.
Constructor Summary | |
---|---|
JpaExecutor(javax.persistence.EntityManager entityManager)
Constructor taking an EntityManager directly. |
|
JpaExecutor(javax.persistence.EntityManagerFactory entityManagerFactory)
Constructor taking an EntityManagerFactory from which the
EntityManager can be obtained. |
|
JpaExecutor(JpaOperations jpaOperations)
If custom behavior is required a custom implementation of JpaOperations
can be passed in. |
Method Summary | |
---|---|
void |
afterPropertiesSet()
Verifies and sets the parameters. |
protected java.util.List<?> |
doPoll(ParameterSource jpaQLParameterSource)
|
java.lang.Object |
executeOutboundJpaOperation(Message<?> message)
Executes the actual Jpa Operation. |
java.lang.Object |
poll()
Execute the JPA operation. |
java.lang.Object |
poll(Message<?> requestMessage)
Execute a (typically retrieving) JPA operation. |
void |
setDeleteAfterPoll(boolean deleteAfterPoll)
If set to 'true', the retrieved objects are deleted from the database upon being polled. |
void |
setDeleteInBatch(boolean deleteInBatch)
If not set, this property defaults to false , which means that
deletion occurs on a per object basis if a collection of entities is being
deleted. |
void |
setEntityClass(java.lang.Class<?> entityClass)
Sets the class type which is being used for retrieving entities from the database. |
void |
setExpectSingleResult(boolean expectSingleResult)
This parameter indicates that only one result object shall be returned as a result from the executed JPA operation. |
void |
setJpaParameters(java.util.List<JpaParameter> jpaParameters)
|
void |
setJpaQuery(java.lang.String jpaQuery)
|
void |
setMaxNumberOfResults(int maxNumberOfResults)
Set the max number of results to retrieve from the database. |
void |
setNamedQuery(java.lang.String namedQuery)
A named query can either refer to a named JPQL based query or a native SQL query. |
void |
setNativeQuery(java.lang.String nativeQuery)
You can also use native Sql queries to poll data from the database. |
void |
setParameterSource(ParameterSource parameterSource)
Specifies the ParameterSource that would be used to provide
additional parameters. |
void |
setParameterSourceFactory(ParameterSourceFactory parameterSourceFactory)
|
void |
setPersistMode(PersistMode persistMode)
|
void |
setUsePayloadAsParameterSource(java.lang.Boolean usePayloadAsParameterSource)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JpaExecutor(javax.persistence.EntityManagerFactory entityManagerFactory)
EntityManagerFactory
from which the
EntityManager
can be obtained.
entityManagerFactory
- Must not be null.public JpaExecutor(javax.persistence.EntityManager entityManager)
EntityManager
directly.
entityManager
- Must not be null.public JpaExecutor(JpaOperations jpaOperations)
JpaOperations
can be passed in. The implementations themselves typically provide access
to the EntityManager
.
See also DefaultJpaOperations
and AbstractJpaOperations
.
jpaOperations
- Must not be null.Method Detail |
---|
public void afterPropertiesSet()
ParameterSourceFactory
.
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
public java.lang.Object executeOutboundJpaOperation(Message<?> message)
message
-
public java.lang.Object poll(Message<?> requestMessage)
parameterSourceFactory
. If the
requestMessage parameter is null then
parameterSource
is being used for providing query parameters.
requestMessage
- May be null.
public java.lang.Object poll()
poll(Message)
.
protected java.util.List<?> doPoll(ParameterSource jpaQLParameterSource)
public void setEntityClass(java.lang.Class<?> entityClass)
entityClass
- Must not be null.public void setJpaQuery(java.lang.String jpaQuery)
jpaQuery
- The provided JPA query must neither be null nor empty.public void setNativeQuery(java.lang.String nativeQuery)
nativeQuery
- The provided SQL query must neither be null nor empty.public void setNamedQuery(java.lang.String namedQuery)
namedQuery
- Must neither be null nor emptypublic void setPersistMode(PersistMode persistMode)
public void setJpaParameters(java.util.List<JpaParameter> jpaParameters)
public void setUsePayloadAsParameterSource(java.lang.Boolean usePayloadAsParameterSource)
public void setDeleteInBatch(boolean deleteInBatch)
false
, which means that
deletion occurs on a per object basis if a collection of entities is being
deleted.
If set to 'true' the elements of the payload are deleted as a batch
operation. Be aware that this exhibits issues in regards to cascaded deletes.
The specification 'JSR 317: Java Persistence API, Version 2.0' does not
support cascaded deletes in batch operations. The specification states in
chapter 4.10:
"A delete operation only applies to entities of the specified class and
its subclasses. It does not cascade to related entities."
deleteInBatch
- Defaults to 'false' if not set.public void setDeleteAfterPoll(boolean deleteAfterPoll)
deleteAfterPoll
- Defaults to 'false'.public void setParameterSourceFactory(ParameterSourceFactory parameterSourceFactory)
parameterSourceFactory
- Must not be nullpublic void setParameterSource(ParameterSource parameterSource)
ParameterSource
that would be used to provide
additional parameters.
parameterSource
- Must not be null.public void setExpectSingleResult(boolean expectSingleResult)
true
and
the result list from the JPA operations contains only 1 element, then that
1 element is extracted and returned as payload.
If the result map contains more than 1 element and
expectSingleResult
is true
, then a
MessagingException
is thrown.
If set to false
, the complete result list is returned as the
payload.
public void setMaxNumberOfResults(int maxNumberOfResults)
maxNumberOfResults
- Must not be negative.Query.setMaxResults(int)
|
Spring Integration | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |