使用Hibernate的session执行任意SQL语句以及整个事务

Session session =  getSession(); 
        session.beginTransaction(); 
        Query query = session.createQuery("update Useraccount set meeting=meeting+1,useMeeting=useMeeting-1 where userId=(select userId from Signup where id="+signupID+") and chargesbasis=(select a.chargesbasis  from Signup as s,Activities as a where s.id="+signupID+" and s.activitiesId=a.id)"); 
        query.executeUpdate(); 
        query=session.createQuery("delete from Signup where id="+signupID); 
        query.executeUpdate(); 
        session.beginTransaction().commit(); 
        if(session!=null){ 
            session.close(); 
        }
很简单的哈

你可能感兴趣的:(使用Hibernate的session执行任意SQL语句以及整个事务)