emacarron / mybatis

Automatically exported from code.google.com/p/mybatis
0 stars 0 forks source link

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

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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(ExceptionFactor 
y.java: 
8) 
        at 
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlS 
ession.java: 
61) 
        at 
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlS 
ession.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

Original issue reported on code.google.com by dutrieux...@gmail.com on 25 Sep 2010 at 9:12

GoogleCodeExporter commented 9 years ago
I ran into this problem as well. Adding parameterType="map" to my select 
statement fixed the issue, but as Duto says, java.util.Map should be the 
default parameterType; not java.lang.Object

Original comment by aaron.pi...@gmail.com on 10 Jun 2011 at 5:22

GoogleCodeExporter commented 9 years ago
It seems to be possible with a tiny modification.

Original comment by haraw...@gmail.com on 14 Jan 2012 at 6:08

Attachments:

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r4571.

Original comment by haraw...@gmail.com on 14 Jan 2012 at 1:36

GoogleCodeExporter commented 9 years ago
Thank you for the report!

Original comment by haraw...@gmail.com on 14 Jan 2012 at 1:37

GoogleCodeExporter commented 9 years ago
Issue 149 has been merged into this issue.

Original comment by eduardo.macarron on 15 Jan 2012 at 12:11