Hi guys, Fairly new to Apache Camel. I have a Camel program which parses some XML using Jaxb and then inserts the parsed objects into the database using open JPA. The example is very similar to the Camel ETL example. At the moment I have the application persisting records from the XML however it is only persisting the first record!
I'm looking for some advice on how to change the application so that it inserts all parsed objects (all items in my case). My item XML looks like this... <?xml version="1.0" encoding="UTF-8"?> <WEB-ITM-EXT-FIL> <WEB-ITM-EXT-REC> <WEB-ITM-EXT-DATA> <ITEM-NO>93501250080</ITEM-NO> <DESCRIPTION>KHOMBU APFOOTA KOKO HIGH</DESCRIPTION> </WEB-ITM-EXT-DATA> </WEB-ITM-EXT-REC> <WEB-ITM-EXT-REC> <WEB-ITM-EXT-DATA> <ITEM-NO>93501250090</ITEM-NO> <DESCRIPTION>TEST</DESCRIPTION> </WEB-ITM-EXT-DATA> </WEB-ITM-EXT-REC> </WEB-ITM-EXT-FIL> Here is what my route looks like... from("file:src/data?fileName=FIT.XML&noop=true") .convertBodyTo(ItemRootDocument.class) .split().method(ItemDocumentService.class, "splitItemsDocuments") .log("Split line ${body}") .to("jpa:org.apache.camel.example.etl.ItemEntity"); Here is my Split... public List<ItemDocument> splitItemsDocuments(ItemRootDocument doc) { ItemDocuments itemDocuments = doc.getItemDocumentsList().get(0); return itemDocuments.getItemDocumentList(); } And my ItemTransformer to convert to an ItemEntity looks like this... public class ItemTransformer { @Converter public ItemEntity toItem(ItemDocument doc, Exchange exchange) throws Exception { JpaTemplate template = exchange.getIn().getHeader("CamelJpaTemplate", JpaTemplate.class); String itemNo = doc.getItemNo(); ItemEntity item = new ItemEntity(); item.setItemNo(itemNo); item.setDescription(doc.getDescription()); return item; } So it splits the Items in the XML document and persists but only persists the first one. How would I change this so that all parsed items are split? Thanks -- View this message in context: http://camel.465427.n5.nabble.com/JPA-component-Persist-1-record-working-but-how-to-persist-many-records-tp5742267.html Sent from the Camel - Users mailing list archive at Nabble.com.