Skip to content

Commit 8a4d18e

Browse files
Peter Köhleremacarron
Peter Köhler
authored andcommitted
https://code.google.com/p/mybatis/issues/detail?id=72
1 parent daac2fa commit 8a4d18e

7 files changed

+932
-2
lines changed

README.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
1-
ibatis2mybatis
2-
==============
1+
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.
2+
3+
Usage:
4+
Put Your old ibatis2 sqlmap files in the source folder and execute the ant build file.
5+
The task converts Your sqlmap2 files to myBatis mappers in the destination folder and reports anything it cannot convert in the console.
6+
7+
Have fun and maybe You can post some improvements/bugfixes as this initial version is by no means perfect yet!
8+
9+
Greetings from Frankfurt/Germany
10+
11+
Peter Köhler
12+

build.xml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
Copyright 2010-2013 the original author or authors.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<project name="migrate to mybatis3" basedir="." default="migrateToMyBatis3">
18+
<target name="migrateToMyBatis3">
19+
<!-- delete possible results from previous run -->
20+
<delete>
21+
<fileset dir="destination" includes="*.xml"/>
22+
</delete>
23+
<!-- xslt convert sqlMaps 2 to mybatis 3 -->
24+
<xslt basedir="source" style="migrate.xslt" includes="*.xml" destdir="destination" extension=".xml"/>
25+
<!-- replace #id:NUMERIC# to #id,jdbcType=NUMERIC# etc. -->
26+
<replace dir="destination" includes="*.xml" token=":NUMERIC#" value=",jdbcType=NUMERIC#" encoding="UTF8"/>
27+
<replace dir="destination" includes="*.xml" token=":TIMESTAMP#" value=",jdbcType=TIMESTAMP#" encoding="UTF8"/>
28+
<replace dir="destination" includes="*.xml" token=":VARCHAR#" value=",jdbcType=VARCHAR#" encoding="UTF8"/>
29+
<replace dir="destination" includes="*.xml" token=":BLOB#" value=",jdbcType=BLOB#" encoding="UTF8"/>
30+
<!-- add any needed jdbc type here (for example :CLOB#, :FLOAT#, :REAL#, :BIT#, :INTEGER#, :DECIMAL#, :DATE#, :TIME#, .... )
31+
<replace dir="destination" includes="*.xml" token=":???#" value=",jdbcType=???#" encoding="UTF8"/>
32+
-->
33+
<!-- replace $id$ with ${id} -->
34+
<replaceregexp match="\$([a-zA-Z0-9.\[\]_]+)\$" replace="$\{\1}" flags="mg" byline="false" encoding="UTF8">
35+
<fileset dir="destination" includes="*.xml" />
36+
</replaceregexp>
37+
<!-- replace #id# with #{id} -->
38+
<replaceregexp match="#([a-zA-Z0-9,_.=\[\]]{2,})#" replace="#{\1}" flags="mg" byline="false" encoding="UTF8">
39+
<fileset dir="destination" includes="*.xml" />
40+
</replaceregexp>
41+
<!-- replace xyz[] with item for use in iterators-->
42+
<replaceregexp match="[a-z.]{2,}\[\]" replace="item" flags="ig" encoding="UTF8">
43+
<fileset dir="destination" includes="*.xml" />
44+
</replaceregexp>
45+
46+
<xmlvalidate failonerror="yes" lenient="false" warn="yes">
47+
<attribute name="http://apache.org/xml/features/validation/schema" value="false" />
48+
<attribute name="http://xml.org/sax/features/namespaces" value="false" />
49+
<fileset dir="destination" includes="*.xml" />
50+
<dtd publicId="-//mybatis.org//DTD SQL Map Config 3.0//EN" location="mybatis-3-config.dtd" />
51+
<dtd publicId="-//mybatis.org//DTD Mapper 3.0//EN" location="mybatis-3-mapper.dtd" />
52+
</xmlvalidate>
53+
54+
</target>
55+
</project>

destination/Ger_your_new_mybatis3_mapper_files_here.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)