This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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!