普通设置
定义
<sql id="personCols">
DISPLAY, NAME, PHONE, ADDRESS, BIRTHDATE, REMARK
</sql>
使用
<insert id="insertPerson" parameterType="priv.dengjl.ns.bean.Person"
useGeneratedKeys="true" keyProperty="id">
INSERT INTO PERSON(
<include refid="personCols"></include>
)
VALUES(#{display}, #{name},
#{phone}, #{address}, #{birthdate},
#{remark})
</insert>
别名设置 (举例说明)
定义
<sql id="personCols">
${alias}.DISPLAY, ${alias}.NAME, ${alias}.PHONE, ${alias}.ADDRESS, ${alias}.BIRTHDATE, ${alias}.REMARK
</sql>
使用
<insert id="insertPerson" parameterType="priv.dengjl.ns.bean.Person"
useGeneratedKeys="true" keyProperty="id">
INSERT INTO PERSON(
<include refid="personCols">
<property name="alias" value="p"/>
</include>
)
VALUES(#{display}, #{name},
#{phone}, #{address}, #{birthdate},
#{remark})
</insert>