2 Replies Latest reply: Nov 28, 2011 5:11 PM by Mohit Handa RSS

    Persisting a list of entities using jpa endpoint

    Mohit Handa Newbie

       

      Hi Guys,

       

      I am trying to persist a list of entities using a camel route.

       

      So some thing like

       

      exchange.getIn().setBody(BeanToEntityConverter.convertPlanToPlanEntity(plans)); // BeanToEntityConverter.convertPlanToPlanEntity(plans) returns a list of PlanEntity

       

      And following is my route endpoint

       

      .to("jpa:org.myproject.servicebus.services.PlanEntity");

       

      I get the following exception in my logs

       

      at java.lang.Thread.run(Thread.java:662)

      Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: java.util.ArrayList to the required type: org.myproject.servicebus.services.PlanEntity with value [org.myproject.servicebus.services.PlanEntity@3346e3, org.myproject.servicebus.services.PlanEntity@72e235, org.myproject.servicebus.services.PlanEntity@61414d, org.myproject.servicebus.services.PlanEntity@10637dd, org.myproject.servicebus.services.PlanEntity@13d9e14, org.myproject.servicebus.services.PlanEntity@555cb7]

       

      Which actually makes sense to me. But I am really not sure how I could define a jpa endpoint that can persist a list of entities. If I set the exchange body to be a single object i.e. a PlanEntity Object, it works fine.

       

      Any suggestions? Please advise.

       

      Regards,

      Mohit