Tuesday, March 26, 2013

Conversion from iBatis 2 to MyBatis 3:

This page provides some information that is useful when migrating a project from iBatis 2 to MyBatis 3. It is probably not 100% complete.

Conversion Tool

There is a tool available in the downloads section that will help you to convert your iBATIS 2.x sqlmap files into MyBatis 3.x xml mapper files.
The tool is designed around an xslt transformation and some text replacements packaged in an ant task and tries to deliver a good starting point before the more complex work begins.

New DTDs

New sqlMapConfig.xml DTD:
New sqlMap (*.map.xml) DTD:


  • Root configuration tag  is now 


Within the root configuration tag:
 x="y" foo="bar"/>
is now:

     name="x" value="y"/>
     name="foo" value="bar"/>
can be removed, since the use of namespaces has become mandatory.

 must be moved out of the  element to 



... />


 type="JDBC" commitRequired="false">
     type="your.package.CustomDataSourceFactory" />
is now:
             name="commitRequired" value="false"/>
         type="your.package.CustomDataSourceFactory" />

 resource=... />
 resource=... />
 resource=... />
is now:

     resource=... />


  • The root element  is now 
  • The attribute parameterClass should be changed to parameterType
  • The attribute resultClass should be changed to resultType
  • The attribute class should be changed to type
  • the columnIndex attribute does not exist anymore for the  tag
  • The groupBy attribute has been eliminated. Here is an example of groupBy from a 2.x sqlMap:
 id="productRM" class="product" groupBy="id">
     property="id" column="product_id"/>
     property="name" column="product_name"/>
     property="category" column="product_category"/>
     property="subProducts" resultMap="Products.subProductsRM"/>
 id="productRM" type="product" >
     property="id" column="product "/>
     property="name " column="product_name "/>
     property="category " column="product_category "/>
     property="subProducts" resultMap="Products.subProductsRM"/>

Nested resultMaps

These should now be specified using the  tag.
     property="client" resultMap="Client.clientRM"/>
is now:
     property="client" resultMap="Client.clientRM"/>

Although this tag is deprecated, it can be used as in iBatis 2. However for versions up to 3.0.3 there is a bug when using type="map" and not specifying javaType for a parameter. This will result in
There is no getter for property named '...' in 'interface java.util.Map'    
This should be solved in MyBatis 3.0.4. For versions 3.0.3 and earlier the workaround is to explicitly specify javaType.

Inline parameters

is now:

jdbcType changes

is now:
is now:

Stored procedures

  • the  tag doesn't exist anymore. Use  or .
 id="getValues" parameterMap="getValuesPM">
    { ? = call pkgExample.getValues(p_id => ?) }
is now:
If you're calling an insert procedure that returns a value, you can use  instead of , but make sure to specifyuseCache="false" and flushCache="true". You'll also have to force a commit.
  • for stored procedures that return a cursor, there is a bug (see  issue 30 ) when using nested result maps (i.e. the output parameter's resultMap contains an  tag with the resultMap attribute). As long as the issue is not fixed, you have to specify the resultMap of the output parameter on the statement itself as well, or the nested resultMap will not be populated.


 id="myCache" type="LRU">
     name="size" value="100" />
is now:
 flushInterval="86400000" eviction="LRU"/>
Note: you can omit eviction="LRU" since it is the default.
  • the  tag is replaced by the flushCache attribute for the statements and the cache will be used by all select statements by default.

Dynamic SQL

The most common dynamic SQL in my project is isNotNull. Here is an example replacement regex:
 test="$1 != null">
Also common is the use of isEqual, you can replace this by a similar  tag.

Java code


  • This class doesn't exist anymore. Use SqlSessionFactory instead (see User Guide).

Custom type handler

  • Replace interface TypeHandlerCallback with TypeHandler. It has slightly different but similar methods.

Custom data source factory

Old interface:
New interface:
Replace method
public void initialize(Map properties)
public void setProperties(Properties props)


Anonymous said...

Therefore, the characters must sell animal skins in order to get money for buying
the weapons. So even at young ages and relatively low levels of the sport,
goalies will have their helmets designed with various colors,
prints and patterns, shapes or designs, and more. If you have ever tried to kid yourself that everything will be fine and glossed over certain issues because you wanted to avoid them, or did
not know how to deal with them. It scored a decent 3208 marks in the PCMark04 benchmark.
In doing so, it becomes the only potential choice for best gaming PC under 500 bucks in the desktop category.
"What have you Googled lately. In 2005, the QI Group acquired a UK-based independent telecommunications provider with a strong background in providing advanced communications solutions and technology in the United Kingdom. In an effort to counter the lack of support from Microsoft, an SVG plug-in for Internet Explorer was developed and supported by Adobe. * You're realistic about what you expect from others. A Whole Lot of Exciting Options to Choose from Advanced car wash equipment use low-flow technology that drastically reduces drying times for carpets and upholstery.

Review my website :: http://canadamomeh.ca/PauletteM

Anonymous said...

Wacom is probably the first stop for such a device, although Aiptek also make some of the most popular tablets
on the market. For most young people, playing games on a
computer, video game console, or handheld device is
just a regular part of the day. You're punished more than and in excess of for generating faults in education and encouraged never ever to do it.

my website :: http://atarsolfa.bloghi.com/2013/02/27/effortless-solutions-in-games-what-s-required.html

Anonymous said...

What's up friends, pleasant post and fastidious arguments commented at this place, I am in fact enjoying by these.

Feel free to visit my blog post :: get money

Anonymous said...

It's very easy to find out any topic on web as compared to books, as I found this paragraph at this website.

Review my web site :: twitter account

Anonymous said...

I really like what you guys are up too. This type of
clever work and exposure! Keep up the awesome works guys I've added you guys to my own blogroll.

Look into my page - Bret Fulker

Anonymous said...

Hi, i think that i saw you visited my site thus i came to return
the choose?.I am attempting to find issues to improve my site!
I suppose its ok to use some of your ideas!

Have a look at my web-site: p-tweets.com

Anonymous said...

Wow, this article is nice, my younger sister is analyzing these kinds of things,
thus I am going to inform her.

Feel free to visit my page - ミュウミュウ

Anonymous said...

Hiya very nice website!! Guy .. Beautiful .
. Wonderful .. I will bookmark your web site and take the feeds also?
I am satisfied to find a lot of helpful info here within the publish, we want develop
more techniques in this regard, thank you for sharing.
. . . . .

Feel free to surf to my blog ... polo ralph lauren outlet

Anonymous said...

Howdy! I simply wish to give you a big thumbs up
for the great information you have got here on this post.
I am coming back to your site for more soon.

My web-site; Polo Ralph Lauren Factory Store

Anonymous said...

Fastidious answers in return of this issue with real arguments and explaining the whole thing regarding that.

Here is my web page ... Psn Code Generator

Anonymous said...

Exсellent рieces. Keep posting such κind оf infoгmаtion οn уour site.
Im really іmpresseԁ bу yοur site.

Thanκѕ foг shaгіng уour
thοughtѕ аbout κeуworԁ.

Heгe iѕ mу web page ... payday loans

Anonymous said...

Can I post your post to my wordpress weblog? I will add a one-way link
to your forum. That’s one actually great post.

Also visit my web site - trying to conceive tips

Anonymous said...

e cigarette, best electronic cigarettes, electronic cigarettes, smokeless cigarettes, e cigarette, e cigarette

Anonymous said...

what is the mybatis equivalent for ibatis's queryForMap() and executeBatch()

Anonymous said...

What did change here? Do you really check before posting?

These should now be specified using the tag.
property="client" resultMap="Client.clientRM"/>

is now:
property="client" resultMap="Client.clientRM"/>

raybanoutlet001 said...

fitflops sale
cheap air jordans
huarache shoes
nike huarache sale
cheap jordans
air jordan shoes
michael kors handbags
cheap jordans online
michael kors outlet
michael kors outlet
nike huarache
michael kors handbags,michael kors handbags clearance,michael kors clearance
nfl jerseys from china
true religion store
nmd adidas store
air jordan shoes
adidas yeezy boost
michael kors outlet online
tiffany and co outlet
adidas stan smith
tiffany jewelry
ugg outlet