Show Table of Contents
6.4. Processing and Persisting an Order
- To process and persist an XML "order" message, you should bind the order data into the Order entities (Order, OrderLine and Product). To do this, create and populate the Order and OrderLine entities using the Java Binding framework.
- Wire each OrderLine instance into the Order instance.
- In each OrderLine instance, you should lookup and wire in the associated order line Product entity.
- Finally, insert (persist) the Order instance as seen below:
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd" xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.4.xsd" xmlns:dao="http://www.milyn.org/xsd/smooks/persistence-1.2.xsd"> <jb:bean beanId="order" class="example.entity.Order" createOnElement="order"> <jb:value property="ordernumber" data="ordernumber" /> <jb:value property="customerId" data="customer" /> <jb:wiring setterMethod="addOrderLine" beanIdRef="orderLine" /> </jb:bean> <jb:bean beanId="orderLine" class="example.entity.OrderLine" createOnElement="order-item"> <jb:value property="quantity" data="quantity" /> <jb:wiring property="order" beanIdRef="order" /> <jb:wiring property="product" beanIdRef="product" /> </jb:bean> <dao:locator beanId="product" lookupOnElement="order-item" onNoResult="EXCEPTION" uniqueResult="true"> <dao:query>from Product p where p.id = :id</dao:query> <dao:params> <dao:value name="id" data="product" decoder="Integer" /> </dao:params> </dao:locator> <dao:inserter beanId="order" insertOnElement="order" /> </smooks-resource-list> - If you want to use the named query
productByIdinstead of the query string, the DAO locator configuration will look like this:<dao:locator beanId="product" lookupOnElement="order-item" lookup="product.byId" onNoResult="EXCEPTION" uniqueResult="true"> <dao:params> <dao:value name="id" data="product" decoder="Integer"/> </dao:params> </dao:locator>

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.