Re: Undefined mapping should be mapped "naturally" in <resultMap>

23 views
Skip to first unread message

Eduardo Macarron

unread,
Oct 4, 2012, 8:42:56 AM10/4/12
to mybati...@googlegroups.com
Hi Frederic. MyBatis by default tries to map all columns to properties so I am afraid that the feature you are asking for is already in place. 
Have a look at:
http://www.mybatis.org/core/sqlmap-xml.html#Auto-mapping
Is that what you are asking for?

Frédéric Camblor

unread,
Oct 4, 2012, 10:54:06 AM10/4/12
to mybati...@googlegroups.com
Wow ! Sounds great !

That's exactly what I want :-)

When I was saying I'm perhaps lacking in knowledge... this was true !

Just a last question regarding the FULL auto-mapping : if I use the "columnPrefix" xml attribute on <association> and <collection> tags, shouldn't it fix the issue pointed in the example ?

That is to say, if I enrich the documentation example :

<select id="selectBlog" parameterType="int" resultMap="blogResult">
  select
    B.id,
    B.title,
    A.username as 'author.username',
  from Blog B left outer join Author A on B.author_id = A.id
  where B.id = #{id}
</select>

<resultMap id="blogResult" type="Blog">
  <association property="author" columnPrefix="author." javaType="Author" resultMap="authorResult"/>
</resultMap>


<resultMap id="authorResult" type="Author">
  <result property="username" column="author_username"/>
</resultMap>
wouldn't it nice ?

Thanks again though,

Frédéric Camblor  
Bordeaux JUG Board member
Jenkins community member & plugin commiter

Eduardo Macarron

unread,
Oct 5, 2012, 6:07:33 AM10/5/12
to mybati...@googlegroups.com
Sounds good indeed. I would try, I would not be surprised if that does already work!

2012/10/4 Frédéric Camblor <fcam...@gmail.com>
Reply all
Reply to author
Forward
0 new messages