I am having trouble with fitting in the jpa entity. Not able to find the
correct syntax to do it.
I tried the below, but no data went into the database. The println's do
print out the entity data.
@Override
public void process(Exchange exchange) throws Exception {
MarsTracerEntity entity = new MarsTracerEntity();
if(null != exchange.getIn().getHeader("CamelFileNameOnly"))
entity.setInputFileName((String)exchange.getIn().getHeader("CamelFileNameOnly"));
if(null != exchange.getIn().getHeader("CamelBatchSize"))
entity.setBatchSize((Integer)exchange.getIn().getHeader("CamelBatchSize"));
if(null != exchange.getIn().getHeader("breadcrumbId"))
entity.setOutputFileName((String)exchange.getIn().getHeader("breadcrumbId"));
System.out.println("InputFilename 5555 :
"+entity.getInputFileName());
System.out.println("outputFilename 2222 :
"+entity.getOutputFileName());
System.out.println("Batch 1111 : "+entity.getBatchSize());
exchange.getIn().setBody(entity);
JpaEndpoint endpoint = (JpaEndpoint) exchange.getContext()
.getEndpoint("jpa://org.apache.camel.processor.interceptor.JpaTraceEventMessage?persistenceUnit=tracer");
JpaTemplate jpaTemplate = endpoint.getTemplate();
jpaTemplate.persist(entity);
}
Entity def:
@Entity
@Table(name="MarsTrace")
public class MarsTracerEntity implements Serializable{
The intercept config in the Camel Context.
<intercept>
<process ref="marsTraceProcessor"/>
</intercept>
--
View this message in context:
http://camel.465427.n5.nabble.com/convert-Exchange-Headers-to-JPA-Entity-tp5077846p5078708.html
Sent from the Camel - Users mailing list archive at Nabble.com.