-----------------ibatis取不到数据---------------

Brokenfango 2008-09-09 11:41:33
<resultMap id="frResult" class="Friend">
<result property="id" column="ID"/>
<result property="uId" column="U_ID"/>
<result property="fId" column="F_ID"/>
</resultMap>
<resultMap id="fsResult" class="java.util.HashMap">
<result property="id" column="ID"/>
<result property="uId" column="U_ID"/>
<result property="fId" column="F_ID"/>
</resultMap>
<select id="getFById" parameterClass="java.lang.Integer" resutlMap="frResult">
<![CDATA[
select * from fs where id=#value#
]]>
</select>
<select id="getFList" parameterClass="java.lang.Integer" resutlMap="fsResult">
<![CDATA[
select * from fs where u_id=#value#
]]>
</select>

fs表确实有数据 可是取出来的数据为空!!
请大侠们看看问题出在哪里??

...全文
77 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
song1216 2008-09-11
  • 打赏
  • 举报
回复
up
Brokenfango 2008-09-09
  • 打赏
  • 举报
回复
f.getUserId()-->f.getUId();
Brokenfango 2008-09-09
  • 打赏
  • 举报
回复
import java.io.Serializable;
public class Friend implements Serializable{
private int id;
private int uId;//
private int fId;//
//
public Friend(int uId,int fId){
this.uId = uId;
this.fId = fId;
}
//
public Friend(){

}
//getters and setters
public void setId(int id){
this.id = id;
}
public int getId(){
return this.id;
}
public void setUId(int uId){
this.uId = uId;
}
public int getUId(){
return this.uId;
}
public void setFId(int fId){
this.fId = fId;
}
public int getFId(){
return this.fId;
}
}

try {
reader = Resources.getResourceAsReader ("sqlmap_cfg.xml");
sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
Object obj = sqlMap.queryForObject("getFById",4);
if (obj == null) {
System.out.println("obj = null");
} else {
Friend f = (Friend) obj;
System.out.println(f.getUserId());
}
} catch (SQLException e){
e.printStackTrace();
}

输出 obj = null
Brokenfango 2008-09-09
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 c2one 的回复:]
select * from fs where id=#id# 试试

或者
<select id="getFById" parameterClass="String" resutlMap="frResult">
<![CDATA[
select * from fs where id=#value#
]]>
</select>
[/Quote]
这样也不行哈

我取别的表的数据是可以的 取这个表就是不行
jinsu_st 2008-09-09
  • 打赏
  • 举报
回复
把你DAO层的代码贴上来一起看
c2one 2008-09-09
  • 打赏
  • 举报
回复
select * from fs where id=#id# 试试

或者
<select id="getFById" parameterClass="String" resutlMap="frResult">
<![CDATA[
select * from fs where id=#value#
]]>
</select>

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧