-
Mar 14th, 2011, 02:58 PM
#1
Help with implementation of DB/File CompositeWriter
We are having trouble getting a seemingly simple Composite Writer configuration working properly. The composite is writing to a file and also to a hsql database.
The problem we are seeing is that the auto-commit must be set to true for the DB writes to be committed. The flat file is written out correctly, but the database is empty unless the auto-commit flag is set as previously mentioned. (Note: If we input special code to explicitly commit, then the data is stored in the DB) I have the feeling we are NOT setting up the DAO as an item stream correctlyb but not really sure.
A stripped down test setup is shown below. Would appreciate any help.
<code>
The job config looks likes :
<batch:step id="loadImports">
<batch:tasklet>
<batch:chunk reader="importReader" processor="importProcessor" writer="compositeWriter" commit-interval="1">
<batch:streams>
<batch:stream ref="itemDAO"/>
<batch:stream ref="fileWriter"/>
</batch:streams>
</batch:chunk>
</batch:tasklet>
</batch:step>
Composite Writer is defined as:
<bean id="compositeWriter" class="org.springframework.batch.item.support.Comp ositeItemWriter" scope ="step">
<property name="delegates">
<list>
<ref bean="itemDAO"/>
<ref bean="fileWriter"/>
</list>
</property>
</bean>
ItemDAO
public class ItemDAO extends implements ItemStream,ItemWriter<aobject> {
}
itemDAO Is:
<bean id="itemDAO" name="itemDAO" class="com.dao.ADAO" autowire-candidate="true">
<property name="dataSource" ref="hsqlSource" />
</bean>
the FileWriter is :
<bean id="fileWriter" class="org.springframework.batch.item.file.FlatFil eItemWriter">
<property name="resource" value="${loadFile}" />
<property name="lineAggregator" ref="loadAggregator"/>
</bean>
</code>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules