Results 1 to 2 of 2

Thread: read from 3 tables

  1. #1
    Join Date
    Nov 2009
    Posts
    16

    Default read from 3 tables

    hallo every body

    i want to read from 3 tables in daba base and write the results to flat file csv
    so in my xml file i create a itemreader bean like this
    Code:
    	<bean id="TitresReader"
    		class="org.springframework.batch.item.database.JdbcCursorItemReader">
    		<property name="dataSource" ref="dataSource" />
    		<property name="sql"
    			value="SELECT titres_mil_ccs.cc_id,
    					titres_cc.cc_lib,
    					ref_n1.id_grn,
    					'0700' as duree, 
    					'unité' as unite_oeuvre ,
    					'0' as prix,
    					titres_mil_ccs.mil_code,
    					'' as date_inactivation,
    					'' as date_inactivite
    					FROM titres_mil_ccs inner join titres_cc on titres_mil_ccs.cc_id = titres_cc.cc_id
    					cross join ref_n1
    					" />
    		<property name="rowMapper">
    			<bean class="batch.CCS"/>           
    		</property>
    	</bean>

    and here is my item writer
    Code:
    	<bean id="TitresWriter" class="org.springframework.batch.item.file.FlatFileItemWriter">
    		<property name="resource" value="file:target/test-outputs/Titres.csv" />
    		<property name="lineAggregator">
    			<bean
    				class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
    				<property name="delimiter" value=";" />
    				<property name="fieldExtractor">
    
    					<bean
    						class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor">
    						<property name="names" value="ccId,IdGrn" />
    					</bean>
    				</property>
    			</bean>
    		</property>
    	</bean>

    but the problem is in my itemReader i cant mappe to all colum in my SQL statement

    for exemple i can mappe cc_lib from class titres_cc but how can i mappe to other colum ?

  2. #2
    Join Date
    Feb 2008
    Posts
    488

    Default

    You need to define a bean for a class that implements RowMapper. See http://static.springsource.org/sprin...rsorItemReader.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •