hibernate循环查询怎么返回的List数组没有变化
dao
public List<T> ListByCondition(String condition) throws DaoException {
try {
return (List<T>)
getHibernateTemplate().find(
" from " + klass.getName() + " where 1=1 " + condition
+ " ");
} catch (DataAccessException e) {
throw new DaoException(getKlass() + ".ListByCondition异常 : "
+ e.toString());
}
}
for循环2次,hibernate返回的list地址一样,sql如下
Hibernate:
select
tzhaobbaoj0_.SN as SN36_,
tzhaobbaoj0_.WUPMC as WUPMC36_,
from
ZHAOB.T_ZHAOB_BAOJ tzhaobbaoj0_
where
1=1
and tzhaobbaoj0_.XIANGMUBH='1222'
and tzhaobbaoj0_.GONGYSBH='598'
[com.yunwang.zhaob.model.TZhaobBaojId@696aa494, com.yunwang.zhaob.model.TZhaobBaojId@e79a2535]
Hibernate:
select
tzhaobbaoj0_.SN as SN36_,
tzhaobbaoj0_.WUPMC as WUPMC36_,
from
ZHAOB.T_ZHAOB_BAOJ tzhaobbaoj0_
where
1=1
and tzhaobbaoj0_.XIANGMUBH='1222'
and tzhaobbaoj0_.GONGYSBH='597'
[com.yunwang.zhaob.model.TZhaobBaojId@696aa494, com.yunwang.zhaob.model.TZhaobBaojId@e79a2535]
这两个sql语句是不一样的,怎么返回的List都是第一个sql语句查询的list
------解决方案--------------------你拿这2句SQL直接去数据库查 看看结果有区别吗~~~如果结果集一样就没问题 。
如果有问题 看下页面的list是如何赋值的~~
------解决方案--------------------那你检查下 是不是你 HIBERNATE 配置文件 属性和列名 配置有误~~所以会造成HIBERNATE 专换成SQL 变成一样了