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"
         class="org.springframework.batch.item.database.HibernateCursorItemReader"
         scope="step">
    <property name="sessionFactory" ref="sessionFactory"/>
    <property name="queryString">
       <value>
          <![CDATA[ from Something where start_date <= :reqFromDate ]]>
       </value>
    </property>
    <property name="parameterValues">
      <map>
        <entry key="reqFromDate" value="#{jobParameters['from_date']}"/>
      </map>
    </property>
  </bean>
Advertisements

4 Comments »

RSS feed for comments on this post. TrackBack URI

  1. This was really helpful for me, thanks for the great post 🙂

  2. Thank you. Really helpful.

  3. Thanks for the post, it resolved my issue

  4. Thanks a lot, this worked like charm, very helpful


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.
Entries and comments feeds.

%d bloggers like this: