Announcement Announcement Module
Collapse
No announcement yet.
PatternMatchingCompositeLineMapper query Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • PatternMatchingCompositeLineMapper query

    Hello Techsters -

    I am facing an issue with PatternMatchingCompositeLineMapper configuration that I have done below:
    Code:
    <beans:bean id="bookFile"
    		class="org.springframework.core.io.FileSystemResource" scope="step">
    		<beans:constructor-arg value="src/main/resources/composite.csv" />
    	</beans:bean>
    
    
    	<beans:bean id="compositeFileReader" class="com.integration.file.transform.CustomBookReader">
    		<beans:property name="delegate" ref="trueBookFileReader" />
    	</beans:bean>
    	<beans:bean id="trueBookFileReader" class="org.springframework.batch.item.file.FlatFileItemReader">
    		<beans:property name="resource" ref="bookFile" />
    		<beans:property name="lineMapper">
    			<beans:bean	class="org.springframework.batch.item.file.mapping.PatternMatchingCompositeLineMapper">
    				<beans:property name="tokenizers">
                        <util:map>
    						<beans:entry key="BOOK*" value-ref="bookLineTokenizer" />
    						<beans:entry key="AUTHOR*" value-ref="authorLineTokenizer" />
    						<beans:entry key="PUBLISHER*" value-ref="publisherLineTokenizer" />
    					</util:map>
    				</beans:property>
    				<beans:property name="fieldSetMappers">
    					 <util:map>
    						<beans:entry key="BOOK*" value-ref="bookFieldSetMapper" />
    						<beans:entry key="AUTHOR*" value-ref="authorFieldSetMapper" />
    						<beans:entry key="PUBLISHER*" value-ref="publisherFieldSetMapper" />
    					 </util:map>
    				</beans:property>
    			</beans:bean>
    		</beans:property>
    	</beans:bean>
    	
    
    	<beans:bean id="bookLineTokenizer" class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
    		<beans:property name="names" value="book,name,price" />
    		<beans:property name="delimiter" value="," />
    	</beans:bean>
    	<beans:bean id="authorLineTokenizer" class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
    		<beans:property name="names" value="author,name" />
    		<beans:property name="delimiter" value="," />
    	</beans:bean>
    	<beans:bean id="publisherLineTokenizer" class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
    		<beans:property name="names" value="publisher,name" />
    		<beans:property name="delimiter" value="," />
    	</beans:bean>
    	
    
            <beans:bean id="book" class="com.app.Book" scope="prototype" />
    	<beans:bean id="author" class="com.app.Author" scope="prototype" />
    	<beans:bean id="publisher" class="com.app.Publisher" scope="prototype" />
    	
    	
    	<beans:bean id="bookFieldSetMapper"	class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">
    		<beans:property name="prototypeBeanName" value="book" />
    		<beans:property name="strict" value="false"/>
    	</beans:bean>
    	
    	<beans:bean id="authorFieldSetMapper" class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">	
    		<beans:property name="prototypeBeanName" value="author" />
    		<beans:property name="strict" value="false"/>
    	</beans:bean>
    	
    	<beans:bean id="publisherFieldSetMapper" class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">	
    		<beans:property name="prototypeBeanName" value="publisher" />
    		<beans:property name="strict" value="false"/>
    	</beans:bean>
    When I run my app, I get the following error:
    Caused by: org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'name' of bean class [com.app.Book]: Duplicate match with distance <= 5 found for this property in input keys: [price, name, book]. (Consider reducing the distance limit or changing the input key names to get a closer match.)

    Apparently the framework is trying to look for a property named "book" as mentioned in the bookLineTokenizer and likewise.

    How do we make sure the BeanWrapperFieldSetMapper does not look for properties that are prefix (patterns in this case).

    If there is a gap in my understanding of how to configure a PatternMatchingCompositeLineMapper please do let me know.

    Regards.
Working...
X