ibaits知识点:如果你要在DaoImpl里面得到一个List的话,我们只要在配置文件里面配置一下resultClass为Long或者是String。
[code]
<select id="selectRoleList" parameterClass="User" resultClass="Long">
select roleid from t_str where stid=(select id from t_student where cardid=#cardId#)
</select>
@SneakyThrows
@SuppressWarnings( { "unchecked" })
@Override
public Boolean add(User user) {
insert("insertUser", user);
Mediator mediator = null;
List<Long> list = queryForList("selectRoleList", user);
for (int i = 0; i < list.size(); i++) {
mediator = new Mediator();
Long pId = list.get(i);
mediator.setOneId(user.getId());
mediator.setOtherId(pId);
insert("addRUMediator", mediator);
}
return true;
}
[/code]
[color=red]List<Long> list = queryForList("selectRoleList", user);[/color]
[code]
<select id="selectRoleList" parameterClass="User" resultClass="Long">
select roleid from t_str where stid=(select id from t_student where cardid=#cardId#)
</select>
@SneakyThrows
@SuppressWarnings( { "unchecked" })
@Override
public Boolean add(User user) {
insert("insertUser", user);
Mediator mediator = null;
List<Long> list = queryForList("selectRoleList", user);
for (int i = 0; i < list.size(); i++) {
mediator = new Mediator();
Long pId = list.get(i);
mediator.setOneId(user.getId());
mediator.setOtherId(pId);
insert("addRUMediator", mediator);
}
return true;
}
[/code]
[color=red]List<Long> list = queryForList("selectRoleList", user);[/color]