1. ibatis 查询单条数据
XML中设置
view plaincopy to clipboardprint?
<select id="login" parameterClass="User" resultMap="user">
SELECT * FROM users where userName=#userName# and password=#password#
</select>
<select id="login" parameterClass="User" resultMap="user">
SELECT * FROM users where userName=#userName# and password=#password#
</select>
JAVA代码
view plaincopy to clipboardprint?
public User login(User user) throws Exception {
user = (User) this.getSqlMapClient().queryForObject(
user.getClass().getName() + ".login", user);
return user;
}
public User login(User user) throws Exception {
user = (User) this.getSqlMapClient().queryForObject(
user.getClass().getName() + ".login", user);
return user;
}
2. 查询多条数据,返回LIST
XML设置
view plaincopy to clipboardprint?
<select id="registerCheck" parameterClass="User" resultMap="user">
SELECT * FROM users where userName=#userName#
</select>
<select id="registerCheck" parameterClass="User" resultMap="user">
SELECT * FROM users where userName=#userName#
</select>
JAVA代码
view plaincopy to clipboardprint?
List list = (List) this.getSqlMapClient().queryForList(
user.getClass().getName() + ".registerCheck", user);
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/xiaxiaorui2003/archive/2009/11/24/4867033.aspx