Composite keys in MyBatis <collection> mappings -


i unable pass composite key mybatis <collection> element (using version 3.2.7). mybatis documentation states:

note: deal composite keys, can specify multiple column names pass nested select statement using syntax column="{prop1=col1,prop2=col2}". cause prop1 , prop2 set against parameter object target nested select statement.

however, attempts implement produce exception

org.mybatis.spring.mybatissystemexception: nested exception org.apache.ibatis.reflection.reflectionexception: error instantiating class java.lang.integer invalid types () or values (). cause: java.lang.nosuchmethodexception: java.lang.integer.<init>()

the collection (which resides in resultsmap) is:

<collection property="foos" oftype="fooobject"     column="{param1=user_id,param2=foo_id}" select="getfoosbyuser" >         <id property="userid" column="user_id" />         <id property="foo" column="foo_id" />         <result property="fooname" column="foo_name" /> </collection> 

it should return arraylist of foo objects. composite key user_id , foo_id. select query is:

    <select id="getfoosbyuser" parametertype="integer" resulttype="fooobject">         select           user_id userid,           foo_id fooid,            foo_name fooname         foo_table         user_id = #{param1}         , foo_id = #{param2}     </select> 

the query works correctly if use 1 parameter, e.g. removed foo_id=#{param2} , use column=user_id in collection, cannot work out how structure column attribute correctly 2 keys. ideas?

mybatis confused using parametertype when there more 1 parameter. modify query mapping this:

<select id="getfoosbyuser" resulttype="fooobject">     select       user_id userid,       foo_id fooid,        foo_name fooname     foo_table     user_id = #{param1}     , foo_id = #{param2} </select> 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -