If I did see that right, you are mixing a processor and a route definition here.
Your Processor does look ok until you set the body.
The endpoint shouldn't be part of the class.
More like the following:

 from("direct:start")
        .process(yourProcessorHere)
.to("jpa://org.apache.camel.processor.interceptor.JpaTraceEventMessage?persistenceUnit=tracer");

regards, Achim

Am 15.12.2011 22:20, schrieb ebinsingh:
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.


--
--
*Achim Nierbeck*


Apache Karaf<http://karaf.apache.org/>  Committer&  PMC
OPS4J Pax Web<http://wiki.ops4j.org/display/paxweb/Pax+Web/>    Committer&  
Project Lead
blog<http://notizblog.nierbeck.de/>

Reply via email to