本帖最后由 relic5 于 2012-07-10 21:43:13 编辑

解决方案 »

  1.   

    先写个main函数,看看与数据库是否连接上咯,然后就是在编译时多写几个测试输出点。
      

  2.   

    可能是spring的事务你没有加上 看看你的spring的配置文件 有没有包含你service的包 或者相应的类上加没加事务的注解
      

  3.   

    事务是否提交?
    如果没有用到事务管理,那可能需要commit;
    ActionContext.getContext().getSession().getTransaction().commit();hibernate配置中也可以设置自动提交 setAutoCommit(false)
      

  4.   

    accountDAO.merge(accountEntity);把merge换成flush试一下。public boolean doRecharge(String account) {
    String userid = ((Integer)ActionContext.getContext().getSession().get("userId")).toString();
    System.out.println("userId====="+userid);
    EmUser user = userDAO.findById(Integer.parseInt(userid));
    EmAccount accountEntity = (EmAccount) accountDAO.findByProperty("emUser",user).get(0);
    if (accountEntity.getAccountAmount()==null) {
    accountEntity.setAccountAmount(Double.parseDouble(account));
    }else{
    accountEntity.setAccountAmount(accountEntity.getAccountAmount()+Double.parseDouble(account));
    }
    accountDAO.persist(accountEntity);
    //accountDAO.merge(accountEntity);
    accountDAO.flush()
    return true;
    }
      

  5.   

    这种情况的发生我所遇到的有两种可能:1、事务配置的问题,虽然不会报错,不过就是不会执行。2、你在配置Hibernate文件的时候,针对你所操作的对象属性设置了update为false.当然这是比较老的写法了。