Need spring jdbc resultset to return list of objects instead of LinkedHashMap

霸气de小男生 提交于 2019-12-12 04:36:46

问题


I am using with a row mapper expecting it wuold return me the list of my objects but instead it is returning me LinkedHasMap. I want resultset to be List of my mapped objects.

Any idea how can i achieve this ?

Config

<int-jdbc:stored-proc-inbound-channel-adapter
                        channel="eventObj" 
                        stored-procedure-name="p_get_completed_data"
                        data-source="dataSource"
                        auto-startup="true"
                        id="completedEventAdpt"
                        ignore-column-meta-data="true"
                        is-function="false"                     
                        return-value-required="false">
        <int:poller max-messages-per-poll="1" fixed-rate="180000"/>     
        <int-jdbc:returning-resultset  name="mapper" row-mapper="mapper" />
    </int-jdbc:stored-proc-inbound-channel-adapter>

<bean id="mapper" class="com.db.mapper.MyMapper"/>

回答1:


Stored procedures can return multiple result sets, keyed by the parameter name.

In your case, you only have one result set, but it's still returned in a map.

Simply add a <transformer/> after the inbound adapter...

<transformer ... expression="payload['mapper']" />


来源:https://stackoverflow.com/questions/24716077/need-spring-jdbc-resultset-to-return-list-of-objects-instead-of-linkedhashmap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!