您的位置:首页 > 其它

ibatis的CURD

2015-09-18 23:55 162 查看

继承 org.springframework.orm.ibatis.support.SqlMapClientDaoSupport类

例如:

public class UserLoginDao extends SqlMapClientDaoSupport(){

public UserInfo getItemById(String userId) {

Map<String, String> params = new HashMap<String, String>(1);

params.put("userId", userId);

return (UserInfo) getSqlMapClientTemplate().queryForObject(user.getItemById , params);

}



同时建立sqlMap 配置文件 :

<sqlMap namespace="user">

<sql id="select_xxx_user">

select xxx.user_id,xxx.login,xxx.mobile FROM GOME_USER gome

</sql>

<select id="getItemById" resultMap="UserInfo" parameterClass="java.util.Map">

<include refid="select_xxx_user"/>

<![CDATA[

where USER_ID=#userId# and removed IS NULL

]]>

</select>

</sqlMap>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: