Announcement Announcement Module
Collapse
No announcement yet.
Bind variables usage in spring batch Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bind variables usage in spring batch

    Currently we are having place holders in sql, it is creating new sql id ever time in db.
    <code>
    select * from customers where age >= '#{jobParameters['age']}'
    and to_number(cust_id) between '#{stepExecutionContext[minValue]}' and
    '#{stepExecutionContext[maxValue]}'
    </code>
    Please let me know how to use bind variables in spring batch.
    Last edited by mailtonbalaji; Sep 26th, 2012, 01:14 AM.

  • #2
    Do you mean binding input parameters into Spring wiring?

    <bean id="citySetter" class="com.xxxxxx.batch.mappers.preparedStatementS etters.CitySetter" scope="step">
    <property name="city" value="#{jobParameters[city]}"/>
    </bean>

    Could you clarify?

    Jeff

    Comment


    • #3
      The values to this sql comes from job parameter. If i use as per your example it is creating new sqlid every time in the database. This is very costly. so avoid this issue we need to use bind variable some thing like this.

      <bean sql="select stud_id,stud_name from studentrecord where branch = :branch" />

      SqlParameterSource namedParameters = new MapSqlParameterSource(
      "branch", Branch);
      ParameterJdbcTemplate.queryForInt(sql, namedParameters);

      but i need some samples.
      Last edited by mailtonbalaji; Sep 27th, 2012, 01:33 PM.

      Comment

      Working...
      X