<select id="getAllUsers" resultClass="com.air.Account"> SELECT * FROM USER_ACCOUNT order by USERID </select> <!-- 无映射 --> <select id="getAllUsers1" resultClass="com.air.Account" parameterClass="string"> SELECT * FROM USER_ACCOUNT WHERE GROUPNAME=#groupName# </select> <!-- 内联映射->实体类 --> <select id="getAllUsers2" resultClass="com.air.Account" parameterClass="string"> SELECT USERID as userid, USERNAME as username, PASSWORD as password, GROUPNAME as groupname FROM USER_ACCOUNT WHERE GROUPNAME=#groupName# </select> <!-- 内联映射->MAP类 --> <select id="getAllUsers3" resultClass="hashmap" parameterClass="string"> SELECT * FROM USER_ACCOUNT WHERE GROUPNAME=#groupName# </select> <!-- 显示映射->实体类 --> <resultMap id="accoutResult" class="com.air.Account"> <result property="userid" column="USERID" /> <result property="username" column="USERNAME" /> <result property="password" column="PASSWORD" /> <result property="groupname" column="GROUPNAME" /> </resultMap> <select id="getAllUsers4" resultMap="accoutResult" parameterClass="string"> SELECT * FROM USER_ACCOUNT WHERE GROUPNAME=#groupName# </select> <!-- 显示映射->MAP类 --> <resultMap id="mapResult" class="hashmap"> <result property="userid" column="USERID" /> <result property="username" column="USERNAME" /> <result property="password" column="PASSWORD" /> <result property="groupname" column="GROUPNAME" /> </resultMap> <select id="getAllUsers5" resultMap="mapResult" parameterClass="string"> SELECT * FROM USER_ACCOUNT WHERE GROUPNAME=#groupName# </select> <!-- XML --> <select id="selectXML" parameterClass="string" resultClass="xml" xmlResultName="log"> SELECT * FROM USER_ACCOUNT WHERE GROUPNAME=#groupName# </select> <select id="getOneUser" resultClass="com.air.Account" parameterClass="string"> SELECT * FROM USER_ACCOUNT WHERE GROUPNAME=#groupName# </select> <!-- 自动参数映射 --> <insert id="insertOneUser1" parameterClass="com.air.Account"> INSERT INTO USER_ACCOUNT ( USERNAME, PASSWORD, GROUPNAME )VALUES( #username#,#password#,#groupname# ) </insert> <!-- 内联参数映射 --> <insert id="insertOneUser2" parameterClass="com.air.Account"> INSERT INTO USER_ACCOUNT ( USERNAME, PASSWORD, GROUPNAME )VALUES( #username:VARCHAR#, #password:VARCHAR#, #groupname:VARCHAR# ) </insert> <!-- 外联参数映射 --> <parameterMap id="parameterMapEx" class="com.air.Account"> <parameter property="username" jdbcType="VARCHAR"/> <parameter property="password" jdbcType="VARCHAR"/> <parameter property="groupname" jdbcType="VARCHAR"/> </parameterMap> <insert id="insertOneUser3" parameterMap="parameterMapEx"> INSERT INTO USER_ACCOUNT ( USERNAME, PASSWORD, GROUPNAME )VALUES( ?,?,? ) </insert> <!-- 自动生成的键 --> <insert id="insertOneUser4" parameterClass="com.air.Account"> INSERT INTO USER_ACCOUNT ( USERID,USERNAME, PASSWORD, GROUPNAME )VALUES( #userid#, #username#, #password#, #groupname# ) <selectKey keyProperty="userid" resultClass="int"> SELECT LAST_INSERT_ID() </selectKey> </insert>