반응형

@notepad_jj2

츄르사려고 코딩하는집사입니다.


IBatis의 xml 동적 태그를 MyBatis xml 동적 태그로 변환하는 코드입니다. 이클립스에서 replace를 할 때, 아래 정규식을 이용하면 동적 태그들을 바꿀 수 있습니다.

아래 관련된 코드들을 메모장 파일로 원하면 메일을 남겨주세요.

 

0. DOCTYPE 변경하기

1) IBatis

<!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD SQL MAP 2.0//EN"
	"http://ibatis.apache.org/dtd/sql-map-2.dtd">

 

2) MyBatis

<!DOCTYPE mapper
  PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

 

3) 변환코드

"-//ibatis.apache.org//DTD SQL MAP 2.0//EN"
"-//mybatis.org//DTD Mapper 3.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"

 

1. sqlMap을 mapper로 변환하기

- sqlMap

- mapper

 

2. isEqual을 if로 변환하기

<isEqual property="([a-zA-Z0-9_A-Z]*)" compareValue="Y">
<if test="$1 == 'Y'">
<isEqual property="([A-Z]*)" compareValue="Y" >
<if test="$1 == 'Y'">

<isEqual property="([a-zA-Z_]*)" compareValue="Y">
<if test="$1 == 'Y'">
<isEqual property="([A-Z_]*[A-Z]*)" compareValue="([A-Z]*)">
<if test="$1 == '$2'">
</isEqual>
</if>
<isEqual property="([a-zA-Z_]*)" compareValue="Y">
<if test="$1 == 'Y'">
<isEqual property="([A-Z_A-Z]*)" compareValue="([0-9]*)">
<if test="$1 == '$2'">
<isEqual property="([A-Z]*)" compareValue="([A-Z0-9]*)">
<if test="$1 == '$2'">
<isEqual property="([A-Z]*)" compareValue="([A-Z]*)" >
<if test="$1 == '$2'">
<isEqual compareValue="([A-Za-z]*)" property="([A-Za-z]*)">
<if test="$2 == '$1'">
<isEqual property="([A-Z_0-9]*)" compareValue="([A-Z]*)">
<if test="$1 == '$2'">
<isEqual property="([A-Z0-9]*)" compareValue="([A-Z]*)">
<if test="$1 == '$2'">
<isEqual compareValue="([A-Z]*)" property="([A-Z0-9]*)">
<if test="$2 == '$1'">
<isEqual property="([A-Za-z0-9]*)" compareValue="([0-9]*)">
<if test="$1 == '$2'">
<isEqual property="([A-Z]*)" compareValue="([A-Z.A-Z]*)">
<if test="$1 == '$2'">

3. isNotEqual을 if로 변환하기

<isNotEqual property="([a-zA-Z0-9_A-Z]*)" compareValue="Y">
<if test="$1 != 'Y'">
<isNotEqual property="([A-Z]*)" compareValue=" ">
<if test="$1 != ' '">
</isNotEqual>
</if>
<isNotEqual property="([a-zA-Z]*)" compareValue="([a-zA-Z0-9]*)">
<if test="$1 != '$2'">
<isNotEqual property="([A-Z0-9]*)" compareValue="([a-zA-Z0-9]*)">
<if test="$1 != '$2'">
<isNotEqual property="([A-Z]*)" compareValue="([A-Z]*)" >
<if test="$1 != '$2'">

 

4. isEmpty를 if로 변환하기

<isEmpty property="([a-zA-Z_]*)">
<if test="$1 == null and $1 ==''">
<isEmpty property="([A-Z0-9]*)">
<if test="$1 == null and $1 ==''">
</isEmpty>
</if>
<isEmpty property="([A-Z0-9_A-Z]*)">
<if test="$1 == null and $1 ==''">

 

5. isNotEmpty를 if로 변환하기

<isNotEmpty property="([a-zA-Z_]*)" >
<if test="$1 != null and $1 !=''">
<isNotEmpty property="([A-Z_A-Z]*)">
<if test="$1 != null and $1 !=''">
<isNotEmpty property="([A-Z0-9A-Z]*)">
<if test="$1 != null and $1 !=''">
<isNotEmpty property="([A-Z_A-Z0-9]*)">
<if test="$1 != null and $1 !=''">
<isNotEmpty property="([A-Z0-9_]*[A-Z_]*[A-Z]*)">
<if test="$1 != null and $1 !=''">
<isNotEmpty property="([A-Z]*)">
<if test="$1 != null and $1 !=''">

 

6. $$ 를 ${}로 변환하기

\$([a-z]*)\$
\${$1}
\$([A-Z_]*[A-Z]*)\$
\${$1}
\$([A-Z0-9]*)\$
\${$1}


7. ## 를 #{}로 변환하기

\#([A-Z]*)\#
\#{$1}
\#([A-Z_0-9]*)\#
\#{$1}

 

 

8. iterate를 foreach로 변환하기

<iterate property="([A-Z_A-Z_A-Z]*)" conjunction=" ">
<foreach collection="$1" separator=" ">
</iterate>
</foreach>

 

9. parameterClass 변경

parameterClass
parameterType

 

10. resultClass 변경

resultClass
resultType
반응형
  • 네이버 블러그 공유하기
  • 네이버 밴드에 공유하기
  • 페이스북 공유하기
  • 카카오스토리 공유하기