Hibernate基础知识详解

匿名 (未验证) 提交于 2019-12-02 22:10:10

一、Hibernate框架


https://hibernate.org/orm/releases/
二、ORM(对象关系映射)模型框架




三、Hibernate配置文件

      <hibernate-mapping>             <class name="*.*.*" table="t_customer" catalog="***">                 <id name="id" column="c_id">                     <generator class="identity" />                 </id>                                  <property name="name" column="c_name" length="20" />                                  <set name="orders" inverse="false" cascade="save-update">                     <key column="c_customer_id" />                 </set>             </class>         </hibernate-mapping>















<hibernate-configuration>             <session-factory>                 <!-- 配置关于数据库连接的四个项 driverClass url username password -->                 <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>                 <property name="hibernate.connection.url">jdbc:mysql:///**</property>                 <property name="hibernate.connection.username">***</property>                 <property name="hibernate.connection.password">***</property>                  <!-- 设置连接提供者 -->                 <property name="hibernate.connection.provider_class">org.hibernate.c3p0.internal.C3P0ConnectionProvider</property>                 <!-- c3p0连接池的配置 -->                 <property name="hibernate.c3p0.max_size">20</property> <!-- 最大连接池 -->                 <property name="hibernate.c3p0.min_size">5</property> <!-- 最小连接数 -->                 <property name="hibernate.c3p0.timeout">120</property> <!-- 超时 -->                 <property name="hibernate.c3p0.idle_test_period">3000</property> <!-- 空闲连接 -->                  <!-- 可以将向数据库发送的sql显示出来 -->                 <property name="hibernate.show_sql">true</property>                 <!-- 格式化sql -->                 <property name="hibernate.format_sql">true</property>                  <!-- hibernate的方言 -->                 <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>                  <!-- 自动创建表 -->                 <property name="hibernate.hbm2ddl.auto">create</property>                  <!-- 用于设置事务提交方式 -->                 <property name="hibernate.connection.autocommit">false</property>                  <!-- 配置hibernate的映射文件所在位置 -->                 <mapping resource=".././*.hbm.xml" />                              </session-factory>         </hibernate-configuration>    

注意:无论是映射文件还是核心配置文件,都要有约束在xml文件中,已3.0.dtd为例:

 <!DOCTYPE hibernate-configuration PUBLIC            "-//Hibernate/Hibernate Configuration DTD 3.0//EN"                 "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

位置是:hibernate的jar包下的\project\etc\hibernate.properties
四、Hibernate工作原理:







五、Hibernate持久化类与 主键生成策略








六、Hibernate持久化对象状态








七、Hibernate注解开发

















八、Hibernate检索方式概述






九、Hibernate事务管理

<property name="hibernate.connection.isolation">4</property>















标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!