column="{prop1=col1,prop2=col2} not auto generate a java.util.Map

77 views
Skip to first unread message

Olivier Dutrieux

unread,
Jul 4, 2010, 5:33:00 AM7/4/10
to mybatis-user
Hello everybody

When I don't specify the parameterType on the nested select statement
for a association (nested select) I get this error :

Exception in thread "main"
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause:
org.apache.ibatis.reflection.ReflectionException: There is no setter
for property named 'id' in 'class java.lang.Object'
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### Cause: org.apache.ibatis.reflection.ReflectionException: There is
no setter for property named 'id' in 'class java.lang.Object'
at
org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:
8)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:
61)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:
53)
at
org.apache.ibatis.binding.MapperMethod.executeForList(MapperMethod.java:
82)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:
63)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:35)

my mapper.xml

<resultMap id="result-building" type="beans.Building">
<id property="id"/>
<result property="label"/>
</resultMap>

<select id="selectBuilding" resultMap="result-building">
select
RFBAT00F.EUKLCD as "id",
RFBAT00F.EUS0TX as "label"
from BFREF.RFBAT00F
<where>
<if test="id != null">
RFBAT00F.EUKLCD = #{id}
</if>
</where>
</select>

<resultMap id="result-room" type="beans.Room">
<id property="id.building" column="buildingId"/>
<id property="id.floor" column="floorId"/>
<id property="id.room" column="roomId"/>
<association property="building" column="{id=buildingId}"
select="selectBuilding" />
</resultMap>

<select id="selectAllRoom" resultMap="result-room">
select
rfsal00f.evklcd as "buildingId",
rfsal00f.evkmcd as "floorId",
rfsal00f.evkncd as "roomId"
from bfref.rfsal00f
</select>

I need to add parameterType="java.util.Map" on the select statement
"selectBuilding" to work. On iBatis2 it's not necessary and why
column="{id=building}" not auto generate a java.util.Map if the
select statement don't have a parameterType ?

Best regards

Duto

Clinton Begin

unread,
Jul 6, 2010, 10:42:23 AM7/6/10
to mybati...@googlegroups.com
Interesting.  I would expect it to default to Map as well.

Can you log an issue in the issue tracker for this?  For now, I'm glad there's a workaround.

Cheers,
Clinton
Reply all
Reply to author
Forward
0 new messages