wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes Spring Batch: Passing runtime parameters to query in ItemReader using Qeury XML file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Spring Batch: Passing runtime parameters to query in ItemReader using Qeury XML file" Watch "Spring Batch: Passing runtime parameters to query in ItemReader using Qeury XML file" New topic
Author

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

damodar seepana
Greenhorn

Joined: Feb 05, 2013
Posts: 1
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring Batch: Passing runtime parameters to query in ItemReader using Qeury XML file
 
Similar Threads
How to create and access properties without a properties file or class
Steps to configure and use Mysql database with Spring MVC 3.0 without using hibernate.
REST web service return both XML or JSON
Java- XML
Exception in thread "main" org.springframework.jdbc.UncategorizedSQLException: