• Hibernate的四种典型例子(增删改查)


     Hibernate的四种典型例子(增删改查) 
    //查询 
    // Session session=HibernateSessionFactory.getSession(); 
    // session.beginTransaction(); 
    // Query q=session.createQuery("from Info where id=:id"); 
    // q.setInteger("id", 1); 
    // List l=q.list(); 
    // Info i=(Info)l.get(0); 
    // System.out.print(i.getName()+i.getPwd()); 
    // System.out.println("查询成功"); 
    //删除
    // Session session=HibernateSessionFactory.getSession(); 
    // Transaction t=session.getTransaction(); 
    // t.begin(); 
    // Query q=session.createQuery("from Info where name=:name"); 
    // q.setString("name", "kk"); 
    // List l=q.list(); 
    // Info info=(Info)l.get(0); 
    // session.delete(info); 
    // t.commit(); 
    // System.out.print("删除成功"); 
    //添加 
    // Session session=HibernateSessionFactory.getSession(); 
    // Transaction t=session.getTransaction(); 
    // t.begin(); 
    // Info info=new Info(); 
    // info.setId(3); 
    // info.setName("k9999"); 
    // info.setPwd("333"); 
    // session.save(info); 
    // t.commit(); 
    // System.out.print("添加成功"); 

    //修改
    // Session session=HibernateSessionFactory.getSession(); 
    // Transaction t=session.getTransaction(); 
    // t.begin(); 
    // Info info=new Info(); 
    // info.setId(2); 
    // info.setName("dafei"); 
    // info.setPwd("shazi"); 
    // session.update(info); 
    // t.commit(); 
    // System.out.print("修改成功"); 

  • 相关阅读:
    初始样式
    http://necolas.github.io/normalize.css/
    css3 旋转密码特效
    OpenGL_构建GLFW与第一个程序
    [翻译][HTML]CELLPADDING and CELLSPACING
    Internal Server Error
    字体收集
    Create a site by Google Site
    [转载]HTML5游戏前端开发秘籍
    程序结构(1)
  • 原文地址:https://www.cnblogs.com/OP-RONG/p/4200291.html
Copyright © 2020-2023  润新知