...
You can store a Java entity bean in a database by sending it to a JPA producer endpoint. The body of the In message is assumed to be an entity bean (that is, a POJO with an @Entity annotation on it) or a collection or array of entity beans.
If the body is a List of entities, make sure to use entityType=java.util.ArrayList as a configuration passed to the producer endpoint.
If the body does not contain one of the previous listed types, put a Message Translator in front of the endpoint to perform the necessary conversion first.
...
First we need to setup a persistence-unit
in the persistence.xml file:
Wiki Markup |
---|
{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-jpa/src/test/resources/META-INF/persistence.xml} |
org.springframework.orm.jpa.JpaTemplate
which is used by the org.apache.camel.processor.idempotent.jpa.JpaMessageIdRepository
:Wiki Markup |
---|
{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-jpa/src/test/resources/org/apache/camel/processor/jpa/spring.xml} |
org.apache.camel.processor.idempotent.jpa.JpaMessageIdRepository
:Wiki Markup |
---|
{snippet:id=jpaStore|lang=xml|url=camel/trunk/components/camel-jpa/src/test/resources/org/apache/camel/processor/jpa/fileConsumerJpaIdempotentTest-config.xml} |
...