Hibernate之update&delete

来源:互联网 发布:手机性能测试软件 编辑:程序博客网 时间:2024/05/19 09:02
package hibernate;


import org.hibernate.Session;
import org.hibernate.Transaction;


public class Update {


public static void main(String[] args) {
// TODO Auto-generated method stub
Session session=HibernateUtil.currentSession();
Transaction transaction=session.beginTransaction();
// session.createQuery("update T_user t set t.userPass=:pass where user_id=1")

// .setString("pass", "贾")   //参数设置格式

//            .executeUpdate();

session.createQuery("delete T_user t  where user_id=1")
// .setString("pass", "贾")
        .executeUpdate();
transaction.commit();
HibernateUtil.closeSession();
}


}
0 0
原创粉丝点击