The difference between iBatis and myBatis calling stored procedures 1.0 2.0 3.0

Similarities and differences in sqlMapConfig.xml.

 

iBATIS_v1

iBATIS_v2

iBATIS_v3

DOCTYPE

sql-map-config.dtd

sql-map-config-2.dtd

ibatis-3-config.dtd

configuration tab

<sql-map-config>

</sql-map-config>

<sqlMapConfig>

</sqlMapConfig>

<configuration>

</configuration>

sqlMap tag

<sql-map recource../>

<sqlMap recource../>

<mappers>

<mapper recource.. />

</mappers>

 

Similarities and differences in sqlMap mapping

 

iBATIS_v1

iBATIS_v2

iBATIS_v3

DOCTYPE

sql-map.dtd

sql-map-2.dtd

ibatis-3-mapper.dtd

sqlMap tag

<sql-map>

</sql-map>

<sqlMap>

</sqlMap>

<mapper>

</mapper>

statement tag

<mapped-statement>

</mapped-statement>

<select></select>

<update></update>

<statement></>…

<select></select>

<update></update>

 

parameter representation

#id#

#id#

#{id}

 

Similarities and differences of sqlMap API

 

iBATIS_v1

iBATIS_v2

iBATIS_v3

execution object

SqlMap

SqlMapClient

SqlSession

get executed

XMLSqlMapBuilder->

builderSqlMap

SqlMapClientBuilder->

builderSqlMap

SqlSessionFactory->

openSession

implement

shakeQueryForObject

queryForObject..

queryForList…

update…

selectOne…

selectList…

update…

For the mapping file, the first is a series of attribute name changes, these are just name changes, the usage and meaning have not changed:

  • Like the global configuration file, the root element is also adjusted from <sqlMap> to <mapper> due to changes in DTD constraints.
  • The parameterClass attribute of elements such as <select> has been changed to the parameterType attribute.
  • The resultClasss attribute of elements such as <select> has been changed to the resultType attribute.
  • The class attribute of elements such as <parameterMap> has been changed to the type attribute.
  • The columnIndex attribute of the <result> element has been removed.
  • Nested parameters changed from #value# to #{value}.
  • In the value of the jdbcType attribute of elements such as <parameter>, the original "ORACLECURSOR" value has been changed to the current "CURSOR", and the "NUMBER" value has been changed to "NUMERIC"

The biggest change in MyBatis in coding is to change one of the most commonly used APIs from SqlMapClient to SqlSessionFactory

According to the habit of iBatis, we usually name the global configuration file sqlMapConfig.xml. The file name itself is not required. In MyBatis, the file is often named Configuration.xml.

The DTD constraints of the version are different, and the DTD file of MyBatis has been included in the mybatis-3.0.x.jar package under the release package. This directly affects that the root element of the iBatis configuration file is <sqlMapConfig>, while MyBatis uses <configuration>

1.1 How to set properties in iBatis

<settings props1="value1" props2="value2"… /> 

1.2 How to set properties in myBatis

<settings>
<setting name="props1" value="value1"/>
<setting name="props2" value="value2"/>
</settings>

2.1 How to specify mapping files in iBatis 
<sqlMap resource=... /> <sqlMap resource=... /> <sqlMap resource=... />

2.2 How to specify mapping files in MyBatis
<mappers>
<mapper resource=... />
<mapper resource=... />
</mappers>

In MyBatis, the <proccedure> element has been removed and is defined by <select>, <insert> and <update>:

3.1 How to call stored procedures in iBatis

<procedure id="getValues" parameterMap="getValuesPM">
    { ? = call pkgExample.getValues(p_id => ?) }
 </procedure>

3.2 How to call stored procedures in iBatis

<select id="getValues" parameterMap="getValuesPM" statementType="CALLABLE">
    { ? = call pkgExample.getValues(p_id => ?)}
</select>

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325776599&siteId=291194637