Announcement Announcement Module
Collapse
No announcement yet.
Prepared Map for sql-parameter-source-factory Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Prepared Map for sql-parameter-source-factory

    Hello,
    I have question regarding sql-parameter-source-factory.
    I have, lets say this Pojo:
    Code:
    public class Pojo1 {
    	private var1;
            private var2;
     // getters and setters
    }
    In reality my Pojo has more than 40 variables - which is reason of my question.
    Now I send my pojo into channel as Payload of the message and in my integration context simply do:
    Code:
    <int-jdbc:outbound-channel-adapter
    	data-source="targetDb" 
    	channel="output" 
    	query="INSERT INTO POJO1
     	VALUES(:var1,:var2)"
     	sql-parameter-source-factory="spelSource">
    </int-jdbc:outbound-channel-adapter>
    
    <bean id="spelSource" class="org.springframework.integration.jdbc.ExpressionEvaluatingSqlParameterSourceFactory">
    	<property name="parameterExpressions">
    			<map>
    				<entry key="var1" value="payload.getVar1()"/>
    				<entry key="var2" value="payload.getVar2()"/>
    			</map>
    		</property>
    	</bean>
    It works good and I like this logic, but is there any way how to achieve the same, if I have this parameterExpressions Map already prepared (and this Map is my Message Payload) so I dont not want to create it integration context? E.g. to do something like this:
    Code:
    <bean id="spelSource" class="org.springframework.integration.jdbc.ExpressionEvaluatingSqlParameterSourceFactory"> 
    <property name="parameterExpressions" ref=":payload">
    </property>
    </bean>
    This one is not working of course.

    Thak you,
    Jakub

  • #2
    Ok, just in case that someone will face the same problem - solved using this way:
    Code:
    import org.apache.commons.beanutils.BeanMap;
    ...
    pojoMap = new BeanMap(pojo1); //sent as payload
    Code:
    <int-jdbc:outbound-channel-adapter
    	data-source="targetDb" 
    	channel="output" 
    	query="INSERT INTO POJO1
     	VALUES(:payload.bean.var1,:payload.bean.var2)">
    </int-jdbc:outbound-channel-adapter>

    thanks myself,
    Jakub

    Comment

    Working...
    X