I'm supposed to extract data from a particular database and put it into an XML file.
But the data can only be obtained by doing multiple select queries to different tables of the database.
Here is my configuration:
<!-- Reader for getting msisdn -->
<bean id="pagingdbItemReader2"
class="org.springframework.batch.item.database.JdbcPagingItemReader"
scope="step">
<property name="dataSource" ref="dataSource" />
<property name="queryProvider">
<bean
class="org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="selectClause" value="SELECT SUBSTR(DN_NUM,4) AS MSISDN" />
<property name="fromClause"
value="FROM contr_services_cap cs, directory_number d" />
<property name="whereClause"
value="WHERE co_id in (select co_id from contract_all where customer_id =:CUSTOMER_ID)
AND cs.dn_id = d.dn_id
AND cs.sncode = 1
AND CS.MAIN_DIRNUM = 'X'" />
<property name="sortKey" value="MSISDN" />
</bean>
</property>
<property name="parameterValues">
<map>
<entry key="CUSTOMER_ID" value="#{jobParameters['CUSTOMER_ID']}" />
</map>
</property>
<property name="pageSize" value="10" />
<property name="rowMapper">
<bean class="com.ooredoo.model.inputDB.MSISDNRowMapper" />
</property>
</bean>
<!-- Writer for getting msisdn -->
<bean id="dbItemWriter2" class="org.springframework.batch.item.xml.StaxEventItemWriter">
<property name="resource" value="file:xml/outputs/DonneesFactureFromDB.xml" />
<property name="marshaller" ref="dbMarshaller2" />
<property name="rootTagName" value="Facture" />
</bean>
<!-- Marshaller for getting msisdn -->
<bean id="dbMarshaller2" class="org.springframework.oxm.xstream.XStreamMarshaller">
<property name="aliases">
<util:map id="aliases">
<entry key="msisdn" value="com.ooredoo.model.inputDB.MSISDN" />
</util:map>
</property>
</bean>
Shall I do ALL this config (and create corresponding java classes) for EVERY query ?
EDIT:
I've done this config to extract data from database using a query "A" (And it worked). So my question is: Am I supposed to write the same configuration (with the reader, the writer, the marshaller...etc) for EVERY query I want to execute... or can I write maybe a kind of "group of queries" that can be executed one after the other and render their results to be written in ONE XML file ???