road of hibernate
来源:互联网 发布:linux关机时执行脚本 编辑:程序博客网 时间:2024/05/18 22:12
1st day of hibernate: Hibenate 初窥
hibernate的开发流程:
1:导入所需要的Jar包(对于初学者,可以导入lib下的所有Jar包和hibernate3.jar);
(一般还需要导入对应的数据库驱动)
2:编写hibernate.cfg.xml配置文件或hibernate.properties文件(该文件主要配置连接数据库的一些信息,
eg: url、driver、username、password and so on.)
3:编写domain对象, at the same time,编写对应的映射文件(eg:domain class is 'User' ,the mapping file
shouldbe 'User.hbm.xml' )
4. 利用hibernate 提供的API进行相应的数据库操作。(eg:Configuration , SessionFactory , Session ,
Transaction, Query , Criteria, Restriction etc)
Hibernate development Process Example Code:
public class Base {
public static void main(String[] args) {
Configuration cfg = new Configuration();
cfg.configure();
SessionFactory sf = cfg.buildSessionFactory();
Session s = sf.openSession();
Transaction tx = s.beginTransaction();
User user = new User();
user.setBirthday(new Date());
user.setName("name");
s.save(user);
tx.commit();
s.close();
System.out.println("end");
}
}
0 0
- road of hibernate
- The road of iTour
- the road of future
- the road of IELTS
- the road of IELTS
- Road of poj-1001
- Road of poj-1002
- The road of x264 setting optimization
- The Road of Hacking PostgreSQL (1)
- Road of Tools’ Web site improvement.
- road
- Road
- Road
- Road
- Road
- road
- Java学习之路 --The Road Of Java Study
- Java学习之路 --The Road Of Java Study
- if switch判断结构
- Simple IPTables Firewall with Whitelist and Blacklist
- C语言的数据类型
- Fedora 20 安装后要做的事
- uboot的一点工作
- road of hibernate
- 在Python代码中调用windows command的方法
- HDU:1754 I Hate It
- 学海无涯之程序员
- dump文件保存
- LPC1788FBD208笔记(002):SDRAM实验
- poj 2392 Space Elevator(多重背包)
- 关于信息登记的一点心得
- 容器适配器实现栈