Use jobParameters value in HibernateCursorItemReader HQL

October 8, 2010 at 5:03 pm | Posted in Uncategorized | 4 Comments
Tags: , ,

When ItemReader, ItemWriter, or ItemProcessor need to use JobParameters, you can set their bean scope to “step” and able to reference parameters.

  • doesn’t need to use spring3
  • bean needs to be a “step” scope.
  • expressions are  “#{}” or “%{}”.
    impl is : org.springframework.batch.core.scope.StepScope.ExpressionHider

Here, I pass “from_date” as jobParameter, and bind it to the item reader HQL of HibernateCursorItemReader.

  <bean id="hibernateReader"
    <property name="sessionFactory" ref="sessionFactory"/>
    <property name="queryString">
          <![CDATA[ from Something where start_date <= :reqFromDate ]]>
    <property name="parameterValues">
        <entry key="reqFromDate" value="#{jobParameters['from_date']}"/>

Blog at
Entries and comments feeds.