Java Reference
In-Depth Information
Listing 11-11. hibernate.cfg.xml
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
<mapping class="com.apress.springbatch.chapter11.domain.Customer"/>
<mapping class="com.apress.springbatch.chapter11.domain.Order"/>
<mapping class="com.apress.springbatch.chapter11.domain.OrderItem"/>
When you build and run the job as is, you can confirm that 100 items are read and 100 items are
written (as specified in the OrderGenerator class) to your JMS queue using either the JobRepository
directly or checking in Spring Batch Admin. In either case, you're ready to begin building the batch job
that does the work.
Loading Orders Into the Database
The first step real step of the job (step 2 in actuality) reads orders from the JMS queue and stores them in
your database for further processing. This step, like many before, consists only of XML configuration.
You need to configure a JMSItemReader to obtain the orders from the queue and a HibernateItemWriter
to store the objects in your database. However, before you look at the configuration for the ItemReader
and ItemWriter, Listing 11-12 has the code for the Customer , Order , and OrderItem objects, showing their
Hibernate mappings.
Listing 11-12. Hibernate Mappings for Customer , Order , and OrderItem
package com.apress.springbatch.chapter11.domain;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Version;
public class Customer implements Serializable{
private static final long serialVersionUID = 1L;
Search WWH ::

Custom Search