日期:2014-05-20  浏览次数:20804 次

iBatis查询字段丢失的问题.
在用ibatis查询时,ibatis把一些字段给丢掉了.
配置如下:
<select   id= "readMovie "   parameterClass= "java.lang.Integer "   resultClass= "movie ">
select   id,   cn_name,   keyword,   en_name,   area,
language,   play_Time,   corporation,   show_Time,   create_Time,
recommend,   introduction,   grade,   format,   quality,  
number,   orders   from   vod_movie
where   id   =   #movieId#
</select>


DAO层查询代码下如:
public   Movie   readMovie(int   movieId)   {
logger.debug( "读取影片信息.   传入参数:   movieId   =   "   +   movieId);

return   (Movie)getSqlMapClientTemplate().queryForObject( "readMovie ",   new   Integer(movieId));
}

要询询完成后,发现ibatis把我的一些字段自动给去掉:日志如下:
  -   读取影片信息.   传入参数:   movieId   =   1
2007-03-29   10:49:26,328   DEBUG   (java.sql.Connection:27)   -   {conn-100000}   Connectio
n
2007-03-29   10:49:26,343   DEBUG   (java.sql.Connection:27)   -   {conn-100000}   Preparing
  Statement:         select     id,   cn_name,   keyword,   en_name,   area,           language,   play_T
ime,   corporation,   show_Time,   create_Time,           recommend,   introduction,   grade,   fo
rmat,   quality,             number,   orders   from   vod_movie       where   id   =   ?
2007-03-29   10:49:26,468   DEBUG   (java.sql.PreparedStatement:27)   -   {pstm-100001}   Ex
ecuting   Statement:         select     id,   cn_name,   keyword,   en_name,   area,           language,
  play_Time,   corporation,   show_Time,   create_Time,           recommend,   introduction,   gr
ade,   format,   quality,             number,   orders   from   vod_movie       where   id   =   ?
2007-03-29   10:49:26,468   DEBUG   (java.sql.PreparedStatement:27)   -   {pstm-100001}   Pa
rameters:   [1]
2007-03-29   10:49:26,468   DEBUG   (java.sql.PreparedStatement:27)   -   {pstm-100001}   Ty
pes:   [java.lang.Integer]
2007-03-29   10:49:26,500   DEBUG   (java.sql.ResultSet:27)   -   {rset-100002}   ResultSet
2007-03-29   10:49:26,562   DEBUG   (java.sql.ResultSet:27)   -   {rset-100002}   Header:   [i
d,   keyword,   area,   language,   corporation,   recommend,   introduction,   grade,   format,
  quality,   number,   orders]
2007-03-29   10:49:26,562   DEBUG   (java.sql.ResultSet:27)   -   {rset-100002}   Result:   [1
,   13,   132,   123,   123,   123,   123,   3,   rmvb,   123,   0,   123]

大家注意看上面的一行,只有在Header:[i
d,   keyword,   area,   language,   corporation,   recommend,   introduction,   grade,   format,   quality,   number,   orders]之类的字段才能取到值,其它字段为null。无法得值。

数据库确定有值。不知道是什么问题。

------解决方案--------------------