• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Spring Batch: Passing runtime parameters to query in ItemReader using Qeury XML file  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all ,

I have used late binding in passing query at run time and it is running fine using properties file .Below is implementaion I have used

<bean id="placeholderProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="path to your properties file, either classpath: ... or c:/... " />
</bean>

In properties file :

sql=\
SELECT \
ID, \
NAME \
FROM TEST \
ORDER BY ID
Or starting from Spring 3, you can use SpEL:
<util:properties id="myProperties" location="..." />
...
<beans:bean ...
<beans:property name="sql" value="${sql}"/>
</beans:bean>

Now my actual requirement is to do same operation using XML file.I have prepared xml file as below

Queries.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE queries
[
<!ELEMENT queries (nativeQuery)>
<!ELEMENT nativeQuery (queryName,query)>
<!ELEMENT queryName (#PCDATA)>
<!ELEMENT query (#PCDATA)>
]>
<queries>
<nativeQuery>
<queryName>transactionQuery</queryName>
<query>select TRN_SERIAL from transactions</query>
</nativeQuery>
</queries>

In batch job I have configured using this line

<import resource="Queries.xml" />
but I'm unable to bind query in required place
<bean name="payoutReader" id="payoutReader" class="org.springframework.batch.item.database.JdbcCursorItemReader">
<property name="dataSource" ref="dinero-dataSource" />
<property name="sql" value="transactionQuery" />
<property name="rowMapper">
<bean name="mapper" id="mapper" class="com......." />
</property>
</bean>

please guide me in resolving this

Thanks
D.S
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!