首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

org.hibernate.exception.DataException: 请好手帮忙

2012-12-16 
org.hibernate.exception.DataException: 请高手帮忙这个是错误org.hibernate.exception.DataException: c

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类型,寒一个
[解决办法]
这个错误解决了吗,楼主,应该怎么修改呢

热点排行