-
Sep 25th, 2012, 12:36 PM
#1
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 at 01:14 AM.
-
Sep 26th, 2012, 01:20 PM
#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
-
Sep 26th, 2012, 01:34 PM
#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 at 01:33 PM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules