Thank you Christian and Willem for the reply. I thought of using splitter too but was wondering whether it will take care of all the transaction management(i.e., if one record fails everthing fails) or we have some kind of control with transaction management. And I am pasting the code snippet and error here.Kindly have a look and let me know where am I going wrong. Like Christian pointed out me the JpaProducer but is it something that camel support out of the box or do I need to have some code do it for me. I am just setting the body with arraylist and hoping for jpa endpoint to to take care of it and it gives me the error. Please help. Thanks in advance
ROUTE: ======================================== <route> <from uri="file:D://cameldata/test"/> <process ref="jpaProcessor"/> <to uri="jpa:org.apache.camel.example.spring.DarpanTest"/> </route> BEAN: ======================================== <bean id="jpaProcessor" class="org.apache.camel.example.spring.JPAProcessor"/> <bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent"> <property name="entityManagerFactory" ref="entityManagerFactory"/> </bean> <bean id="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate"> <property name="transactionManager"> <bean class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory"/> </bean> </property> </bean> <bean id="jpaTemplate" class="org.springframework.orm.jpa.JpaTemplate"> <property name="entityManagerFactory" ref="entityManagerFactory"/> </bean> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="persistenceUnitName" value="camel"/> <property name="jpaVendorAdapter" ref="jpaAdapter"/> <property name="dataSource" ref="dataSource" /> </bean> <bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" /> </bean> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /> <property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:SWQA" /> <property name="username" value=" " /> <property name="password" value=" " /> </bean> ENTITY ==================================================== import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; @Entity(name="darpantest") @Table(name="darpantest") public class DarpanTest { @Id @Column(name="testid") private long testid; @Column(name="testname") private String testname; public DarpanTest() { } public long getTestid() { return testid; } public void setTestid(long testid) { this.testid = testid; } public String getTestname() { return testname; } public void setTestname(String testname) { this.testname = testname; } } processor ========================================== public class JPAProcessor implements Processor { @Override public void process(Exchange arg0) throws Exception { Object obj = arg0.getIn().getBody(); GenericFile f = (GenericFile) obj; Object test = f.getBody(); DarpanTest dt = new DarpanTest(); dt.setTestid(10); dt.setTestname("kean"); DarpanTest dt1 = new DarpanTest(); dt1.setTestid(11); dt1.setTestname("bean"); DarpanTest dt2 = new DarpanTest(); dt2.setTestid(12); dt2.setTestname("sha"); DarpanTest dt3 = new DarpanTest(); dt3.setTestid(13); dt3.setTestname("cleo"); List<DarpanTest> li = new ArrayList<DarpanTest>(); li.add(dt); li.add(dt1); li.add(dt2); li.add(dt3); arg0.getIn().setBody(li); } } persistence.xml ================================================= <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0"> <persistence-unit name="camel" transaction-type="RESOURCE_LOCAL"> <class>org.apache.camel.example.spring.DarpanTest</class> <properties> <property name="hibernate.archive.autodetection" value="class"/> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.format_sql" value="true"/> </properties> </persistence-unit> </persistence> stacktrace ============================================= [#2 - file://D://cameldata/test] DefaultErrorHandler ERROR Failed delivery for exchangeId: ID-booradley-50488-1337182823775-0-1. Exhausted after delivery attempt: 1 caught: org.apache.camel.InvalidPayloadRuntimeException: No body available of type: org.apache.camel.example.spring.DarpanTest but has value: [org.apache.camel.example.spring.DarpanTest@e49f9fa, org.apache.camel.example.spring.DarpanTest@44548719, org.apache.camel.example.spring.DarpanTest@9719d5b, org.apache.camel.example.spring.DarpanTest@211c635] of type: java.util.ArrayList on: test.txt. Caused by: No type converter available to convert from type: java.util.ArrayList to the required type: org.apache.camel.example.spring.DarpanTest with value [org.apache.camel.example.spring.DarpanTest@e49f9fa, org.apache.camel.example.spring.DarpanTest@44548719, org.apache.camel.example.spring.DarpanTest@9719d5b, org.apache.camel.example.spring.DarpanTest@211c635] on the exchange: Exchange[test.txt] org.apache.camel.InvalidPayloadRuntimeException: No body available of type: org.apache.camel.example.spring.DarpanTest but has value: [org.apache.camel.example.spring.DarpanTest@e49f9fa, org.apache.camel.example.spring.DarpanTest@44548719, org.apache.camel.example.spring.DarpanTest@9719d5b, org.apache.camel.example.spring.DarpanTest@211c635] of type: java.util.ArrayList on: test.txt. Caused by: No type converter available to convert from type: java.util.ArrayList to the required type: org.apache.camel.example.spring.DarpanTest with value [org.apache.camel.example.spring.DarpanTest@e49f9fa, org.apache.camel.example.spring.DarpanTest@44548719, org.apache.camel.example.spring.DarpanTest@9719d5b, org.apache.camel.example.spring.DarpanTest@211c635] on the exchange: Exchange[test.txt] at org.apache.camel.component.jpa.JpaEndpoint$1.evaluate(JpaEndpoint.java:295)[camel-jpa-2.9.0.jar:2.9.0] at org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.component.jpa.JpaProducer.process(JpaProducer.java:49)[camel-jpa-2.9.0.jar:2.9.0] at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:115)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:285)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:322)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:352)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:175)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:136)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:140)[camel-core-2.9.0.jar:2.9.0] at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:92)[camel-core-2.9.0.jar:2.9.0] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)[:1.6.0_23] at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)[:1.6.0_23] at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)[:1.6.0_23] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)[:1.6.0_23] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180)[:1.6.0_23] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)[:1.6.0_23] at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)[:1.6.0_23] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)[:1.6.0_23] at java.lang.Thread.run(Thread.java:662)[:1.6.0_23] [#2 - file://D://cameldata/test] GenericFileOnCompletion WARN Rollback file strategy: org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy@790f3a9c for file: GenericFile[D:\cameldata\test\test.txt] [#2 - file://D://cameldata/test] DefaultErrorHandler ERROR Failed delivery for exchangeId: ID-booradley-50488-1337182823775-0-3. Exhausted after delivery attempt: 1 caught: org.apache.camel.InvalidPayloadRuntimeException: No body available of type: org.apache.camel.example.spring.DarpanTest but has value: [org.apache.camel.example.spring.DarpanTest@5b9de9c9, org.apache.camel.example.spring.DarpanTest@5c5fba1c, org.apache.camel.example.spring.DarpanTest@10b3b3a5, org.apache.camel.example.spring.DarpanTest@5d71e34] of type: java.util.ArrayList on: test.txt. Caused by: No type converter available to convert from type: java.util.ArrayList to the required type: org.apache.camel.example.spring.DarpanTest with value [org.apache.camel.example.spring.DarpanTest@5b9de9c9, org.apache.camel.example.spring.DarpanTest@5c5fba1c, org.apache.camel.example.spring.DarpanTest@10b3b3a5, org.apache.camel.example.spring.DarpanTest@5d71e34] on the exchange: Exchange[test.txt] -- View this message in context: http://camel.465427.n5.nabble.com/Help-with-bulk-insert-using-Spring-JPA-hibernate-tp5710457p5710962.html Sent from the Camel - Users mailing list archive at Nabble.com.