MyBatis: Difference between revisions
Jump to navigation
Jump to search
(Created page with "* [https://mybatis.org MyBatis] * [https://ibatis.apache.org iBATIS]") |
No edit summary |
||
Line 1: | Line 1: | ||
==Sql== | |||
<source lang="xml"> | |||
<sql id="userColumns"> | |||
${alias}.id, | |||
${alias}.entered, | |||
${alias}.enterer, | |||
${alias}.amended, | |||
${alias}.amender | |||
</sql> | |||
<select id="selectUsers" resultType="map"> | |||
SELECT | |||
<include refid="userColumns"><property name="alias" value="t1"/></include>, | |||
<include refid="userColumns"><property name="alias" value="t2"/></include> | |||
FROM | |||
M00TM00X00 t1 | |||
LEFT join M00TM00X00 t2 on t1.id = t2.id | |||
</select> | |||
</source> | |||
==Key== | |||
<source lang="xml"> | |||
<insert id="createDataType"> | |||
<selectKey keyProperty="id" resultType="int" order="BEFORE"> | |||
SELECT | |||
nvl(MAX(id),0) + 1 id | |||
FROM | |||
M00TM00X00 | |||
</selectKey> | |||
INSERT INTO M00TM00X00( | |||
id, | |||
data_type_code, | |||
data_type_name, | |||
entered, | |||
enterer | |||
) | |||
VALUES ( | |||
#{id}, | |||
#{dataTypeCode}, | |||
#{dataTypeName}, | |||
SYSDATE, | |||
'SELF' | |||
) | |||
</insert> | |||
</source> | |||
==References== | |||
* [https://mybatis.org/mybatis-3/sqlmap-xml.html Mapper XML Files] | |||
* [https://mybatis.org MyBatis] | * [https://mybatis.org MyBatis] | ||
* [https://ibatis.apache.org iBATIS] | * [https://ibatis.apache.org iBATIS] |
Revision as of 20:35, 4 November 2019
Sql
<sql id="userColumns">
${alias}.id,
${alias}.entered,
${alias}.enterer,
${alias}.amended,
${alias}.amender
</sql>
<select id="selectUsers" resultType="map">
SELECT
<include refid="userColumns"><property name="alias" value="t1"/></include>,
<include refid="userColumns"><property name="alias" value="t2"/></include>
FROM
M00TM00X00 t1
LEFT join M00TM00X00 t2 on t1.id = t2.id
</select>
Key
<insert id="createDataType">
<selectKey keyProperty="id" resultType="int" order="BEFORE">
SELECT
nvl(MAX(id),0) + 1 id
FROM
M00TM00X00
</selectKey>
INSERT INTO M00TM00X00(
id,
data_type_code,
data_type_name,
entered,
enterer
)
VALUES (
#{id},
#{dataTypeCode},
#{dataTypeName},
SYSDATE,
'SELF'
)
</insert>