Java Reference
In-Depth Information
Listing 7-46. hibernate.cfg.xml
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
<mapping class="com.apress.springbatch.chapter7.Customer"/>
Last but not least, you need to actually configure the
org.springframework.batch.item.database.HibernateCusorItemReader . Probably the simplest piece of
the puzzle, this ItemReader implementation requires only two dependencies: a Hibernate
SessionFactory and the HQL string to be executed. Listing 7-47 shows the configuration of the
HibernateCusorItemReader with those two dependencies included as well as injecting query parameters
the same way you did in the JdbcPagingItemReader earlier in this chapter.
Listing 7-47. Configuring the HibernateCursorItemReader
<beans:bean id="customerItemReader"
<beans:property name="sessionFactory" ref="sessionFactory"/>
<beans:property name="queryString"
value="from Customer where city = :city"/>
<beans:property name="parameterValues">
<beans:entry key="city" value="#{jobParameters[city]}"/>
In this example, you used an HQL query as your method of querying the database. There are two
other ways to specify the query to execute. Table 7-3 covers all three options.
Search WWH ::

Custom Search