日期:2014-05-19  浏览次数:20591 次

org.hibernate.exception.DataException: 请高手帮忙
这个是错误
org.hibernate.exception.DataException: could not execute native bulk manipulation query

public void updategoods(int goodid,int count, double money,int pid,int sid) {
// TODO Auto-generated method stub
 Session session=getHibernateTemplate().getSessionFactory().openSession();
  Transaction tran=session.beginTransaction();
  try{
Query right=session.createSQLQuery("update goodsinfo set g_count=g_count-"+count+",g_money=g_money-"+money+",p_id="+pid+",state=1 where g_id="+goodid);
right.executeUpdate();
Query right1=session.createSQLQuery("update enterinfo set e_money=e_money-"+money+" where s_id="+sid);
right1.executeUpdate();
Query right2=session.createSQLQuery("update outboundinfo set o_money="+money+" where s_id="+sid);
right2.executeUpdate();
Query right3=session.createSQLQuery("insert into outgoodsinfo values("+goodid+","+count+","+money+")");
right3.executeUpdate();
tran.commit();
  }catch(Exception e){
  e.printStackTrace();
  }finally{
 session.close();
  }
}
就是因为我这样写所以报错

------解决方案--------------------
hibernate里操作数据用HQL语句,我感觉你那些createSQLQuery()里的语句都不是HQL语句
------解决方案--------------------
hql语句针对的是持久化对象,sql针对的是表
createSQLQuery 不知道这里面有到的是 对象还是表名...
------解决方案--------------------
楼上说的都对。学习了
------解决方案--------------------
createSQLQuery  只能是执行 查询的SQL 吧。
好久没有用hibernate了  看看session.中还有些什么方法
------解决方案--------------------
createSQLQuery  都是进行select操作,我是没这么用过
------解决方案--------------------
刚才说错了 是可以的
------解决方案--------------------
可能是赋值的时候问题吧,改用set方法赋值
------解决方案--------------------
哪家网站的啊,我绝对不用,钱用double类型,寒一个
------解决方案--------------------
这个错误解决了吗,楼主,应该怎么修改呢