- 浏览: 98934 次
- 性别:
- 来自: 北京
文章分类
最新评论
Java代码
1.public class User {
2.
3. private String id;
4. private String name;
5. private String password;
6. private Date createTime;
7. private Date expireTime;
8.
9. public User(){}
10.
11. // getter and setter methods
12. // .....
13.}
public class User {
private String id;
private String name;
private String password;
private Date createTime;
private Date expireTime;
public User(){}
// getter and setter methods
// .....
}
Java代码
1.<hibernate-mapping>
2. <class name="org.darkness.hibernate.User">
3. <id name="id">
4. <generator class="uuid"/>
5. </id>
6. <property name="name"/>
7. <property name="password"/>
8. <property name="createTime"/>
9. <property name="expireTime"/>
10. </class>
11.</hibernate-mapping>
<hibernate-mapping>
<class name="org.darkness.hibernate.User">
<id name="id">
<generator class="uuid"/>
</id>
<property name="name"/>
<property name="password"/>
<property name="createTime"/>
<property name="expireTime"/>
</class>
</hibernate-mapping>
Java代码
1.import org.hibernate.cfg.Configuration;
2.import org.hibernate.tool.hbm2ddl.SchemaExport;
3.
4.public class ExportDB {
5.
6. public static void main(String[] args) {
7.
8. //读取hibernate.cfg.xml文件
9. Configuration cfg = new Configuration().configure();
10.
11. SchemaExport export = new SchemaExport(cfg);
12.
13. export.create(true, true);
14. }
15.}
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
public class ExportDB {
public static void main(String[] args) {
//读取hibernate.cfg.xml文件
Configuration cfg = new Configuration().configure();
SchemaExport export = new SchemaExport(cfg);
export.create(true, true);
}
}
Java代码
1.import java.util.Date;
2.
3.import org.hibernate.Session;
4.import org.hibernate.SessionFactory;
5.import org.hibernate.cfg.Configuration;
6.
7.public class Client {
8.
9. public static void main(String[] args) {
10.
11. //读取hibernate.cfg.xml文件
12. Configuration cfg = new Configuration().configure();
13.
14. //创建SessionFactory
15. SessionFactory factory = cfg.buildSessionFactory();
16.
17. Session session = null;
18. try {
19. session = factory.openSession();
20.
21. //开启事务
22. session.beginTransaction();
23.
24. User user = new User();
25. user.setName("张三");
26. user.setPassword("123");
27. user.setCreateTime(new Date());
28. user.setExpireTime(new Date());
29.
30. //保存数据
31. session.save(user);
32.
33. //提交事务
34. session.getTransaction().commit();
35. }catch(Exception e) {
36. e.printStackTrace();
37. //回滚事务
38. session.getTransaction().rollback();
39. }finally {
40. if (session != null) {
41. if (session.isOpen()) {
42. //关闭session
43. session.close();
44. }
45. }
46. }
47.
48. }
49.}
import java.util.Date;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class Client {
public static void main(String[] args) {
//读取hibernate.cfg.xml文件
Configuration cfg = new Configuration().configure();
//创建SessionFactory
SessionFactory factory = cfg.buildSessionFactory();
Session session = null;
try {
session = factory.openSession();
//开启事务
session.beginTransaction();
User user = new User();
user.setName("张三");
user.setPassword("123");
user.setCreateTime(new Date());
user.setExpireTime(new Date());
//保存数据
session.save(user);
//提交事务
session.getTransaction().commit();
}catch(Exception e) {
e.printStackTrace();
//回滚事务
session.getTransaction().rollback();
}finally {
if (session != null) {
if (session.isOpen()) {
//关闭session
session.close();
}
}
}
}
}
Java代码
1.<hibernate-configuration>
2. <session-factory>
3. <property name="hibernate.connection.url">jdbc:mysql://localhost/hibernate_first</property>
4. <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
5. <property name="hibernate.connection.username">root</property>
6. <property name="hibernate.connection.password">depravedAngel</property>
7. <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
8. <property name="hibernate.show_sql">true</property>
9.
10. <mapping resource="org/darkness/hibernate/User.hbm.xml"/>
11. </session-factory>
12.</hibernate-configuration>
1.public class User {
2.
3. private String id;
4. private String name;
5. private String password;
6. private Date createTime;
7. private Date expireTime;
8.
9. public User(){}
10.
11. // getter and setter methods
12. // .....
13.}
public class User {
private String id;
private String name;
private String password;
private Date createTime;
private Date expireTime;
public User(){}
// getter and setter methods
// .....
}
Java代码
1.<hibernate-mapping>
2. <class name="org.darkness.hibernate.User">
3. <id name="id">
4. <generator class="uuid"/>
5. </id>
6. <property name="name"/>
7. <property name="password"/>
8. <property name="createTime"/>
9. <property name="expireTime"/>
10. </class>
11.</hibernate-mapping>
<hibernate-mapping>
<class name="org.darkness.hibernate.User">
<id name="id">
<generator class="uuid"/>
</id>
<property name="name"/>
<property name="password"/>
<property name="createTime"/>
<property name="expireTime"/>
</class>
</hibernate-mapping>
Java代码
1.import org.hibernate.cfg.Configuration;
2.import org.hibernate.tool.hbm2ddl.SchemaExport;
3.
4.public class ExportDB {
5.
6. public static void main(String[] args) {
7.
8. //读取hibernate.cfg.xml文件
9. Configuration cfg = new Configuration().configure();
10.
11. SchemaExport export = new SchemaExport(cfg);
12.
13. export.create(true, true);
14. }
15.}
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
public class ExportDB {
public static void main(String[] args) {
//读取hibernate.cfg.xml文件
Configuration cfg = new Configuration().configure();
SchemaExport export = new SchemaExport(cfg);
export.create(true, true);
}
}
Java代码
1.import java.util.Date;
2.
3.import org.hibernate.Session;
4.import org.hibernate.SessionFactory;
5.import org.hibernate.cfg.Configuration;
6.
7.public class Client {
8.
9. public static void main(String[] args) {
10.
11. //读取hibernate.cfg.xml文件
12. Configuration cfg = new Configuration().configure();
13.
14. //创建SessionFactory
15. SessionFactory factory = cfg.buildSessionFactory();
16.
17. Session session = null;
18. try {
19. session = factory.openSession();
20.
21. //开启事务
22. session.beginTransaction();
23.
24. User user = new User();
25. user.setName("张三");
26. user.setPassword("123");
27. user.setCreateTime(new Date());
28. user.setExpireTime(new Date());
29.
30. //保存数据
31. session.save(user);
32.
33. //提交事务
34. session.getTransaction().commit();
35. }catch(Exception e) {
36. e.printStackTrace();
37. //回滚事务
38. session.getTransaction().rollback();
39. }finally {
40. if (session != null) {
41. if (session.isOpen()) {
42. //关闭session
43. session.close();
44. }
45. }
46. }
47.
48. }
49.}
import java.util.Date;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class Client {
public static void main(String[] args) {
//读取hibernate.cfg.xml文件
Configuration cfg = new Configuration().configure();
//创建SessionFactory
SessionFactory factory = cfg.buildSessionFactory();
Session session = null;
try {
session = factory.openSession();
//开启事务
session.beginTransaction();
User user = new User();
user.setName("张三");
user.setPassword("123");
user.setCreateTime(new Date());
user.setExpireTime(new Date());
//保存数据
session.save(user);
//提交事务
session.getTransaction().commit();
}catch(Exception e) {
e.printStackTrace();
//回滚事务
session.getTransaction().rollback();
}finally {
if (session != null) {
if (session.isOpen()) {
//关闭session
session.close();
}
}
}
}
}
Java代码
1.<hibernate-configuration>
2. <session-factory>
3. <property name="hibernate.connection.url">jdbc:mysql://localhost/hibernate_first</property>
4. <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
5. <property name="hibernate.connection.username">root</property>
6. <property name="hibernate.connection.password">depravedAngel</property>
7. <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
8. <property name="hibernate.show_sql">true</property>
9.
10. <mapping resource="org/darkness/hibernate/User.hbm.xml"/>
11. </session-factory>
12.</hibernate-configuration>
发表评论
-
hibernate二级缓存攻略
2010-10-20 15:31 575很多人对二级缓存都不太了解,或者是有错误的认识,我一直想写一篇 ... -
精通hibernate学习笔记(8-2)[检索方式]
2010-10-19 13:01 7114、报表查询 报表查询用于对数据分组和统计,完整的HQL语 ... -
精通hibernate学习笔记(8)[检索方式]
2010-10-19 13:00 757提供的检索方式: (1)导航对象图检索方式 (2)OID ... -
精通hibernate学习笔记(7)[检索策略]
2010-10-19 12:55 769Customer和Order为例 1、hibernate检索 ... -
精通hibernate学习笔记(6)[映射类型]
2010-10-19 12:51 744Hibernate映射类型分为两种:内置映射类型和客户化映射类 ... -
精通hibernate学习笔记(4)[操作持久化对象]
2010-10-19 12:47 6821、理解Session的缓存 如果希望一个java对象一直处 ... -
精通hibernate学习笔记(5)[映射组成关系]
2010-10-19 12:46 8521、概念 1.1 聚集关系 在域模型中,有些类由几个 ... -
精通hibernate学习笔记(3)[关联关系]
2010-10-19 12:43 907关联关系分:单向关联 ... -
精通hibernate学习笔记(2)[标志符生成器]
2010-10-19 12:37 5631、increment 标识符生成器 该生成器由Hiber ... -
精通hibernate学习笔记(1)
2010-10-19 12:36 747实体域对象的 持久化模式 1、ORM模式 对象-关 ... -
分析Hibernate的缓存机制
2010-10-19 12:33 612缓存是介于应用程序和 ... -
Hibernate缓存管理
2010-10-19 12:31 5891. Cache简介: 缓存( ... -
Hibernate 学习笔记
2010-10-19 12:28 786原创 hibernate 笔记 收藏 day1 一. h ...
相关推荐
Hibernate入门到精通,分享Hibernate的干货,带你入门,走向精通。
解压后包含hibernate入门所需jar (hibernate常用jar,mysql驱动,Junit4jar)
Hibernate入门案例,提供MyEclipse和Eclipse的项目源文件以及war文件
hibernate入门
Hibernate入门笔记Hibernate入门笔记Hibernate入门笔记Hibernate入门笔记Hibernate入门笔记Hibernate入门笔记Hibernate入门笔记Hibernate入门笔记Hibernate入门笔记Hibernate入门笔记Hibernate入门笔记Hibernate入门...
总共分5部分:1和2为hibernate入门,3为hibernate实体映射,4为hibernate复合主键,5为hibernate实体层设计.
hibernate入门小例子,采用mysql(sql-front)数据库
Hibernate入门教程.pdf
hibernate 入门详细操作步骤 包括hibernate包,实例实现文档····
这是一个关于hibernate入门到精通的书,希望可以帮到你
其实Hibernate本身是个独立的框架,它不需要任何web server或application server的支持。然而,大多数的Hibernate入门介绍都加入了很多非Hibernate的东西,看了这个希望能给你点启示!
struts+hibernate入门实例(eclipse版) author:朱千平 phone:13522080786 qq:200896066
hibernate 入门经典实例 hibernate 入门经典实例 hibernate 入门经典实例 hibernate 入门经典实例 hibernate 入门经典实例
hibernate hibernate入门 hibernate学习 hibernate基础
hibernate入门教程 介绍如何引入Hibernate和搭建
Hibernate入门 - 基础配置,Hibernate入门 - 基础配置
NULL 博文链接:https://moshow.iteye.com/blog/1587008