camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "" <>
Subject Ideas on how to structure JPA endpoint application
Date Sat, 16 Nov 2013 09:08:11 GMT
Hi guys,

I am looking for some general guidance on how I should structure my JPA
endpoint route. i.e. what would be a standard approach to my issue.

My camel route parses an XML document containing many items then inserts the
items into a db using a JPA enpoint. The way I did this was to structure the
route something like this....


ItemDocumentService > splitItemDocument...

	public List<Item> splitItemDocument(ItemDocument doc) {
		List<Item> items = new ArrayList<Item>();
		List<Items> itemDocumentsList = doc.getItems();
	        for (Items itemDocuments : itemDocumentsList) {
		return items;

And then my Type Converter would run through each individual item returned
by the split and return an ItemEntity. JPA would then take care of the rest
and insert into the item table.

Now I have decided to change the structure of my db and have a table which
records batch import runs. For example the batch table would have...


And the item table would have...

To achieve try and achieve this I've restructured my route to look like...

			.process(new Processor() {
			    public void process(Exchange exchange) throws Exception {			        
			        String filename = (String)
			        String body = exchange.getIn().getBody(String.class);

			        ImportPayloadEntity importPayloadEntity = new
			        importPayloadEntity.setLoadDateTime(new Date());

So what I have done is to add a new object inside the header which I can
access in my TypeConverter. And my TypeConverter definitely gets the new
header object. 

Now here comes the question....

How do I best persist the ImportPayloadEntity and the items from here. If I
keep the route as per what I have changed it to, in my type converter I
would need to loop through all the items that JaxB has parsed (could be as
many as 200) and then associate them to the batch table entity
(ImportPayloadEntity). I can't help thinking this is a bad thing to do...

Or perhaps there is a better way to persist the items and the batch record.
Could I please get your thoughts?

I hope I have explained the problem well. Please let me know if more info is


So what that would mean is that if my xml document has 120 individual items
in it the type converter would have tun

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message