首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

hibernate第一个例证

2012-11-15 
hibernate第一个例子?hibernate第一个例子步骤1? 新建web project或者 java project项目2 添加架包3 编写h

hibernate第一个例子



?hibernate第一个例子

步骤

1? 新建web project或者 java project项目

2 添加架包

hibernate第一个例证

3 编写hibernate.cfg.xml

?

?

?

4? 编写实体类

? 单实体

Student.java

?

6 添加log4j.properties

  Configuration cfg=new Configuration().configure();          SessionFactory sf=cfg.buildSessionFactory();                 Session session= sf.openSession();          Transaction tx=session.beginTransaction();          Student s=new Student();          s.setName("测试1");          s.setPassword("22");                    session.save(s);                           session.flush();          tx.commit();          session.close();

?

9? 测试成功

?

热点排行