Reputation: 504
I'm trying to pass a List to Postgresql using Mule ESB.
A simplfied version of my pojo looks like:
public class NewEntry {
private String positionReference;
private String productID;
@XmlElement(required=true, name="PositionReference")
public String getPositionReference() {
return positionReference;
}
public void setPositionReference(String positionReference) {
this.positionReference = positionReference;
}
@XmlElement(required=true, name="ProductID")
public String getProductID() {
return productID;
}
public void setProductID(String productID) {
this.productID = productID;
}
}
This is passed in via a soap webservice as List
until now i've had it simply being transformed into JSON and pumped it out to a file now I would like to insert it into a database, so in my database step I've put a in insert query in along the lines of:
<jdbc:query key="insertrecord" value="INSERT INTO f_intraday_rt(version) VALUES (#[message:productDescription]);"/>
Anyway no matter what message evaluation I use in the VALUES section, I can't get it to insert a value, just errors or blank rows.
How do I unbundle the loop and insert a row per list item?
Thanks
Tom
Upvotes: 2
Views: 1155
Reputation: 33413
Use a collection splitter to split the list of objects into different messages just before your outbound JDBC endpoint. This will perform multiple inserts.
Upvotes: 2
Reputation: 308743
It's one INSERT per entry in the List, so you should loop over the collection and execute the SQL INSERT for each one.
Best to think about batching and transactions. Are they one unit of work?
Upvotes: 0