在数据库中增加ID相同的一条数据后,数据库里可以看出已经增加成功,但我用hibernate以下两种方法查询相同ID的数据时,得到的还是之前查询的数据,新增加的时间没有被找出来,第二种我ssion.flush();还是没有新增的数据,这是为什么?怎么解决呢?
谢谢哪位能指点一下我,谢了。
public ResultInfo findCategoryBlockByBlockId(
Integer blockId,PageInfo pageInfo) {
StringBuffer hql = new StringBuffer();
hql.append("from BlkCategoryBlock b where b.blkBlock.blockId=");
hql.append(blockId);
hql.append(" order by b.id desc");
return find(hql.toString(), pageInfo);
}
public List findCategoryBlockByBlockId(Integer blockId) {
StringBuffer hql = new StringBuffer();
Session session=this.getHibernateTemplate().getSessionFactory().getCurrentSession();
Query query=session.createQuery("from BlkCategoryBlock b where b.blkBlock.blockId=? order by b.id desc");
query.setParameter(0,blockId);
List list=query.list();
session.flush();
return list;
}