Herman Bovens
unread,Dec 15, 2010, 11:21:25 AM12/15/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mybati...@googlegroups.com
Hi,
I'm migrating from iBatis 2.x to MyBatis 3.03.
The project has hundreds of statements using <parameterMap>, so even though it is deprecated I would like to continue to use it for now, and gradually move to inline parameters.
However, I have two problems:
1) Most of the calls are to stored procedures, with a parameterMap of type="map", where the defined properties are used as keys in the map. Using MyBatis 3, this doesn't seem to work anymore, for example:
<parameterMap id="getUsersByProjectParamMap" type="map">
<parameter property="output" javaType="resultset" jdbcType="CURSOR" mode="OUT" resultMap="getUsersByProjectResultMap"/>
<parameter property="ID_PROJECT" mode="IN" jdbcType="VARCHAR"/>
</parameterMap>
Results in this error:
There is no getter for property named 'ID_PROJECT' in 'interface java.util.Map'
Is there a different way to use java.util.Map with the (deprecated) <parameterMap> ?
2) As I said I'd like to gradually move to inline maps, but want to keep the statements compatible so I only have to change the statements in the xml files, not in the java code (I have already changed the use of SqClientMap to SqlSessionFactory, but that was not a big change since it was abstracted). I know I should be able to use parameterType="map" and access the values in the map using e.g. #ID_PROJECT#. However, the results of the stored procedures are currently mapped using result maps, and the mapped result is put back in the map using key "output", but I have no clue how to do that using inline parameters.
So could someone rewrite the following example in MyBatis 3 without <parameterMap>, but in a way that it can be called using a parameter of type java.util.Map containing the parameter values (just like in IBatis 2) ?
<resultMap id="getUsersByProjectResultMap" class="com.example.User">
<result property="id" column="ID" javaType="string"/>
<result property="login" column="LOGIN" javaType="string"/>
<result property="firstName" column="NAME_FIRST" javaType="string"/>
<result property="middleName" column="NAME_MIDDLE" javaType="string"/>
<result property="lastName" column="NAME_LAST" javaType="string"/>
</resultMap>
<parameterMap id="getUsersByProjectParamMap" class="map">
<parameter property="output" javaType="resultset" jdbcType="ORACLECURSOR" mode="OUT" resultMap="getUsersByProjectResultMap"/>
<parameter property="ID_PROJECT" mode="IN" jdbcType="VARCHAR"/>
</parameterMap>
<procedure id="getUsersByProject" parameterMap="getUsersByProjectParamMap">
{ ? = call pkgUsers.getbyidproject (ID_PROJECT => ?) }
</procedure>
That should also help other people trying to migrate from iBatis 2.
Best regards,
Herman Bovens