for(int i=0;i<vtlist.size();i++){
         vt=new Valuest();
         vt=(Valuest)vtlist.get(i);
         getSession().beginTransaction();
                getSession().save(vt);
                getSession().beginTransaction().commit();
         }
        

解决方案 »

  1.   

    tx = session.beginTransaction();
    Connection con=session.connection();
    PreparedStatement stmt=con.prepareStatement("update CUSTOMERS set AGE=AGE+1 "
    +"where AGE>0 ");
    stmt.executeUpdate();
    tx.commit();
      

  2.   

    问题已解决,谢谢各位。public void updateContact(String oldUserId, String newUserId)
                throws HibernateException, SQLException {
            // TODO 自动生成方法存根
            Session session = getSession();
            Transaction transcation = session.beginTransaction();
            Connection con = session.connection();
            StringBuffer sql = new StringBuffer("update contact set userId='")
                    .append(newUserId).append("'").append(" where userId='")
                    .append(oldUserId).append("'");
            PreparedStatement stmt = con.prepareStatement(sql.toString());
            stmt.executeUpdate();
            transcation.commit();
            session.close();
        }