Hibernate参考文档学习笔记——Hibernate入门(四)
2013-11-11 11:46
501 查看
每个人都有潜在的能量,只是很容易被习惯所掩盖,被时间所迷离,被惰性所消磨。
今天的学习任务就是Hibernate的配置,由于Hibernate要屏蔽数据库之间的差异,因此存在着众多的配置参数。
1、 可编程的配置方式
org.hibernate.cfg.Configuration表示应用程序中实体类型到数据库的完整集合,是Hibernate中用于创建org.hibernate.SessionFactory的。
可以采用不同的方式添加映射文件,直接指定映射文件,或指定映射的类。
1.1 指定映射文件
View Code
今天的学习任务就是Hibernate的配置,由于Hibernate要屏蔽数据库之间的差异,因此存在着众多的配置参数。
1、 可编程的配置方式
org.hibernate.cfg.Configuration表示应用程序中实体类型到数据库的完整集合,是Hibernate中用于创建org.hibernate.SessionFactory的。
可以采用不同的方式添加映射文件,直接指定映射文件,或指定映射的类。
1.1 指定映射文件
<?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <!-- a SessionFactory instance listed as /jndi/name --> <session-factory name="java:hibernate/SessionFactory"> <!-- properties --> <property name="connection.datasource">java:/comp/env/jdbc/MyDB</property> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <property name="show_sql">false</property> <property name="transaction.factory_class"> org.hibernate.transaction.JTATransactionFactory </property> <property name="jta.UserTransaction">java:comp/UserTransaction</property> <!-- mapping files --> <mapping resource="org/hibernate/auction/Item.hbm.xml"/> <mapping resource="org/hibernate/auction/Bid.hbm.xml"/> <!-- cache settings --> <class-cache class="org.hibernate.auction.Item" usage="read-write"/> <class-cache class="org.hibernate.auction.Bid" usage="read-only"/> <collection-cache collection="org.hibernate.auction.Item.bids" usage="read-write"/> </session-factory> </hibernate-configuration>
View Code
相关文章推荐
- Django 学习笔记(一)
- carrot 2 LingoClusteringAlgorithm , STCClusteringAlgorithm 和 BisectingKMeansClusteringAlgorithm算法比较
- mysql的bigint类型与php的mysql_insert_id函数造成的bug
- XCode5 更新后 无法提交.a文件
- VS2005批处理调用编译命令
- LoadRunner 技巧之IP欺骗
- ORA-07445: exception encountered: core dump [kkslpli()+199] [SIGSEGV] [ADDR:0x2B5BEC7F5EA0] [PC:0x1E
- 测试PHP的整型(integer)
- C语言二叉树遍历操作
- 表锁,行锁区别
- php数据入库前清理 注意php intval与mysql int 类型区别
- 读取通讯录
- 如何更好地学习unity3d
- 合并两个排好序的单链表
- Ubuntu12.10 64位 + android-ndk-r9 编译ffmpeg遇到的问题
- 项目管理(转载)
- linux 下的sublime
- 阿里2013年双十一准备中的技术突破与亮点
- 深度优先遍历与广度优先遍历算法的C语言实现
- Esxi安装使用了解