Hibernate详细教程

Hibernate学习总结----

一、搭建Hibernate环境

1.在src目录下创建hibernate.cfg.xml配置文件

PS:文件的名字不能改!

复制代码
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC 
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN" 
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>

        <!-- configure the database setting -->
        <property name="connection.username">root</property>
        <property name="connection.password">1234</property>
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="connection.url">jdbc:mysql://localhost:3306/test</property>

        <!-- configure the hibernate setting -->
        <!-- transaction is supported by org.hibernate.dialect.MySQL5InnoDBDialect -->
        <property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<!-- show sql in the console --> <property name="show_sql">true</property>
     <!-- create and update the database automaticlly --> <property name="hbm2ddl.auto">update</property> <!-- javax.persistence.validation.mode默认情况下是auto的,就是说如果不设置的话它是会自动去你的classpath下面找一个 bean-validation**包,但是找不到,所以beanvalitionFactory错误 --> <property name="javax.persistence.validation.mode">none</property> </session-factory> </hibernate-configuration>
复制代码

2. 编写实体类,以Person类为例

复制代码
package test.Hibernate.model;

import java.util.HashSet;
import java.util.Set;

public class Person {
    @Override
    public String toString() {
        return "Person [id=" + id + ", name=" + name + "]";
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Set<String> getAddress() {
        return address;
    }
    public void setAddress(Set<String> address) {
        this.address = address;
    }
    private int id;
    private String name;
    private Set<String> address = new HashSet<String>();
      
}
复制代码

3.编写Person.hbm.xml实体类配置文件

复制代码
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- 
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping package="test.Hibernate.model">
    <class name="Person" table="person">
         <id column="id" name="id" type="int">
             <generator class="native"></generator>
         </id>
         
         <property name="name" column="name" length="50" type="string"></property>
         
         <set name="address" table="address">
             <key column="personId"></key>
             <element column="address" type="string" length="50"></element>
         </set>
    </class>
</hibernate-mapping>
复制代码

4.在hibernate.cfg.xml中加入映射信息

<mapping resource="test/Hibernate/model/Person.hbm.xml" />

5.使用MyEclipse生成SessionFactory

复制代码
package test.Hibernate.SessionFactory;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;

/**
 * Configures and provides access to Hibernate sessions, tied to the
 * current thread of execution.  Follows the Thread Local Session
 * pattern, see {@link http://hibernate.org/42.html }.
 */
public class SessionFactory {

    /** 
     * Location of hibernate.cfg.xml file.
     * Location should be on the classpath as Hibernate uses  
     * #resourceAsStream style lookup for its configuration file. 
     * The default classpath location of the hibernate config file is 
     * in the default package. Use #setConfigFile() to update 
     * the location of the configuration file for the current session.   
     */
    private static final ThreadLocal<Session> threadLocal = new ThreadLocal<Session>();
    private static org.hibernate.SessionFactory sessionFactory;
    
    private static Configuration configuration = new Configuration();
    private static ServiceRegistry serviceRegistry; 

    static {
        try {
            configuration.configure();
            serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
            sessionFactory = configuration.buildSessionFactory(serviceRegistry);
        } catch (Exception e) {
            System.err.println("%%%% Error Creating SessionFactory %%%%");
            e.printStackTrace();
        }
    }
    private SessionFactory() {
    }
    
    /**
     * Returns the ThreadLocal Session instance.  Lazy initialize
     * the <code>SessionFactory</code> if needed.
     *
     *  @return Session
     *  @throws HibernateException
     */
    public static Session getSession() throws HibernateException {
        Session session = (Session) threadLocal.get();

        if (session == null || !session.isOpen()) {
            if (sessionFactory == null) {
                rebuildSessionFactory();
            }
            session = (sessionFactory != null) ? sessionFactory.openSession()
                    : null;
            threadLocal.set(session);
        }

        return session;
    }

    /**
     *  Rebuild hibernate session factory
     *
     */
    public static void rebuildSessionFactory() {
        try {
            configuration.configure();
            serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
            sessionFactory = configuration.buildSessionFactory(serviceRegistry);
        } catch (Exception e) {
            System.err.println("%%%% Error Creating SessionFactory %%%%");
            e.printStackTrace();
        }
    }

    /**
     *  Close the single hibernate session instance.
     *
     *  @throws HibernateException
     */
    public static void closeSession() throws HibernateException {
        Session session = (Session) threadLocal.get();
        threadLocal.set(null);

        if (session != null) {
            session.close();
        }
    }

    /**
     *  return session factory
     *
     */
    public static org.hibernate.SessionFactory getSessionFactory() {
        return sessionFactory;
    }
    /**
     *  return hibernate configuration
     *
     */
    public static Configuration getConfiguration() {
        return configuration;
    }

}
复制代码

6.编写测试类

复制代码
package test.Hibernate.dao;

import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.Test;

import test.Hibernate.SessionFactory.SessionFactory;
import test.Hibernate.model.Person;

public class PersonDao {
    @Test
    public void add(){
        Session session = SessionFactory.getSession();
        Transaction tr = session.beginTransaction();
        //----------------------------------------------
        
        Person p = new Person();
        p.setName("test");
        p.getAddress().add("firstAddr");
        p.getAddress().add("secondAddr");
        p.getAddress().add("thirdAddr");
        p.getAddress().add("fourthAddr");        
        session.save(p);
        
        //----------------------------------------------
        tr.commit();
        SessionFactory.closeSession();
        
    }
    
    @Test
    public void get(){
        Session session = SessionFactory.getSession();
        Transaction tr = session.beginTransaction();
        //----------------------------------------------
        
        Person p = (Person)session.get(Person.class, 2);
        System.out.println(p);
        
        //----------------------------------------------
        tr.commit();
        SessionFactory.closeSession();
    }
}
复制代码

二、主键生成策略

identity:使用数据库的自动增长策略,不是所有数据库都支持,比如oracle就不支持。

sequence:在 DB2,PostgreSQL,Oracle,SAP DB,McKoi 中使用序列(sequence)在使用Oracle数据库时可以使用这一个。

hilo:使用高低位算法生成主键值。只需要一张额外表,所有的数据都支持。

native:根据底层数据库的能力选择 identity、sequence 或者 hilo中的一个。

assigned:手工指定主键值。

uuid:由Hibernate自动生成UUID并指定为主键值。

三、Hibernate映射关系配置

1.一对一映射(以主键关联作为示例)User与IdCard(有外键方)的XML配置:

复制代码
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- 
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping package="test.Hibernate.model">
    <class name="User" table="user">
        <id name="id" type="int" column="id">
            <generator class="native"></generator>
        </id>
        
        <property name="name" type="string" column="name"/>        
        
         <set name="address" table="address">    
            <key column="userId"></key>
            <element column="address" type="string"></element>
        </set>
        
        <one-to-one name="idCard" class="IdCard" cascade="all"></one-to-one>     
    </class>
</hibernate-mapping>
复制代码
复制代码
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- 
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping package="test.Hibernate.model">
    <class name="IdCard" table="idCard">
        <id name="id" type="int" column="id">
            <generator class="foreign">
                <param name="property">user</param>
            </generator>
        </id>
        <property name="number" type="string" column="number"/>        
        <one-to-one name="user" class="User" constrained="true"></one-to-one>
        
    </class>
</hibernate-mapping>
复制代码

2.一对多,多对一(以Father和Children为例)

复制代码
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="test.Hibernate.model">
    <class name="Father" table="father">
        <id name="id" type="int" column="id" >
            <generator class="native"></generator>
        </id>
        <property name="name" type="string" column="name"/>
        <set name="children" cascade="all">
              <key column="fatherId"></key>
            <one-to-many class="Children"/>
        </set>
       
    </class>
</hibernate-mapping>
复制代码
复制代码
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="test.Hibernate.model">
    <class name="Children" table="children">
        <id name="id" type="int" column="id" >
            <generator class="native"></generator>
        </id>
        <property name="name" type="string" column="name"/>
        <many-to-one name="father" class="Father" column="fatherId"></many-to-one>      
    </class>
</hibernate-mapping>
复制代码

3.多对多(以Student和Teacher为例)

PS:有一方的set集合要标明inverse=true(后面会讲)

复制代码
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- 
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping package="test.Hibernate.model">
    <class name="Student" table="student">
        <id name="id" type="int" column="id">
            <generator class="native"></generator>
        </id>
        <property name="name" type="string" column="name" length="20"/>
        
        <set name="teachers" table="student_teacher" inverse="false" >
               <key column="studentId"></key>
               <many-to-many class="Teacher" column="teacherId"></many-to-many>              
           </set>
        
    </class>
</hibernate-mapping>
复制代码
复制代码
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- 
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping package="test.Hibernate.model">
    <class name="Teacher" table="teacher">
        <id name="id" type="int" column="id">
            <generator class="native"></generator>
        </id>
        <property name="name" column="name" type="string" length="20"></property>
       
       <set name="students" table="student_teacher" inverse="true" cascade="all">
               <key column="teacherId"></key>
               <many-to-many class="Student" column="studentId"></many-to-many>
       </set>
       
    </class>
</hibernate-mapping>
复制代码

四、inverse和cascade的区别(个人总结,有不对还望指正)

1.inverse=false在一对多删除时是把孩子的外键设置为null,然后删除父亲,孩子不删除,而casecade=all在一对多删除时是把孩子的外键设置为null,然后删除父亲,然后再删除孩子

2.many to many的时候由一方维护,所以一方要设置inverse=false,但是inverse=true的另一方直接删除会出错,这个时候可以用casecade完成级联删除

3.inverse=false只用于set等集合属性,在one to one关系中可以用casecade完成级联删除

五、使用C3P0连接池

1.需要额外导入3个jar包

2.在hibernate.cfg.xml中加入C3P0配置信息

复制代码
        <!-- C3P0连接池设定-->
        <!-- 使用c3p0连接池  配置连接池提供的供应商-->
        <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
        <!--在连接池中可用的数据库连接的最少数目 -->
        <property name="c3p0.min_size">5</property>
        <!--在连接池中所有数据库连接的最大数目  -->
        <property name="c3p0.max_size">20</property>
        <!--设定数据库连接的过期时间,以秒为单位,
        如果连接池中的某个数据库连接处于空闲状态的时间超过了timeout时间,就会从连接池中清除 -->
        <property name="c3p0.timeout">120</property>
         <!--每3000秒检查所有连接池中的空闲连接 以秒为单位-->
        <property name="c3p0.idle_test_period">3000</property>
复制代码

六、HQL语句

复制代码
@Test
    public void HQLSearch(){
        Session session = SessionFactory.getSession();
        Transaction tr = session.beginTransaction();
        //-----------------------------------------
        
        //common search with where
//        String hql= "select e.id,e.name from User e where e.id>=5 and e.id<=9";
//        Query query = session.createQuery(hql);
//        List list = query.list();        
//        for(Object o : list){            
//            System.out.println(Arrays.toString((Object[])o));
//        }
        
        //paging search
//        String hql= "select e.id,e.name from User e";
//        Query query = session.createQuery(hql);
//        query.setFirstResult(0);
//        query.setMaxResults(10);
//        List list = query.list();        
//        for(Object o : list){            
//            System.out.println(Arrays.toString((Object[])o));
//        }
        
        //search with parameters
//        String hql= "select e.id,e.name from User e where id>=? and id<=?";
//        Query query = session.createQuery(hql)
//                .setParameter(0, 1)
//                .setParameter(1, 3);
//        List list = query.list();        
//        for(Object o : list){            
//            System.out.println(Arrays.toString((Object[])o));
//        }
        
        //search with parameters whose type is collection
//        String hql= "select e.id,e.name from User e where id in (:ids)";
//        Query query = session.createQuery(hql)
//                .setParameterList("ids",new Object[]{1,2,3,8} );
//        List list = query.list();    
//        for(Object o : list){            
//            System.out.println(Arrays.toString((Object[])o));
//        }
        
        
        //-----------------------------------------
        tr.commit();
        SessionFactory.closeSession();
    }
复制代码

七、DML语句

复制代码
@Test
    public void DML(){
        Session session = SessionFactory.getSession();
        Transaction tr = session.beginTransaction();
        //-----------------------------------------
        User u = (User)session.get(User.class, 11);
        
        String sql = "update User set name=? where id>?";
        int result = session.createQuery(sql)
                .setParameter(0, "updated")
                .setParameter(1, 10)
                .executeUpdate();
        System.out.println("count of update:"+result);
        
        //the object's status in session was not updated when the object in database have been changed,so if you want
        //to get the updated object in session,you should use method "refresh".
        session.refresh(u);
        
        System.out.println(u);
        
        //-----------------------------------------
        tr.commit();
        SessionFactory.closeSession();
    }
复制代码

 八、开启二级缓存

1. 需要导入以下jar包

2.在hibernate.cfg.xml中加入以下配置

复制代码
        <!-- 使用二级缓存,默认是未打开的。 -->
        <!-- 指定要使用的缓存的提供商,这也就打开了二级缓存--> 
        <property name="hibernate.cache.use_second_level_cache">true</property>  
        <property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>
        <!-- 开启使用查询缓存 -->
        <property name="cache.use_query_cache">true</property>
        <!-- 指定要使用二级缓存的实体类 -->
        <class-cache usage="read-write" class="test.Hibernate.model.Person" />
复制代码

 九、Hibernate对象状态及转化

 http://www.cnblogs.com/sunniest/p/4539817.html


目录<br><br>前言<br>1. 翻译说明<br>1. 在Tomcat中快速上手<br>1.1. 开始Hibernate之旅<br>1.2. 第一个可持久化类<br>1.3. 映射cat<br>1.4. 与猫同乐<br>1.5. 结语<br>2. 体系结构<br>2.1. 总览<br>2.2. JMX集成<br>2.3. JCA支持<br>3. SessionFactory配置<br>3.1. 可编程配置方式<br>3.2. 获取SessionFactory<br>3.3. 用户自行提供JDBC连接<br>3.4. Hibernate提供的JDBC连接<br>3.5. 可选配置属性<br>3.5.1. SQL Dialects SQL 方言<br>3.5.2. 外连接抓取(Outer Join Fetching )<br>3.5.3. 二进制流<br>3.5.4. 自定义CacheProvider<br>3.5.5. 事务策略配置<br>3.5.6. 绑定SessionFactory到JNDI<br>3.5.7. 查询语言替换 <br>3.6. Logging<br>3.7. 实现NamingStrategy(命名策略)<br>3.8. XML配置文件<br>4. 持久化类(Persistent Classes)<br>4.1. POJO简单示例<br>4.1.1. 为持久化字段声明访问器(accessors)和是否可变的标志(mutators)<br>4.1.2. 实现一个默认的构造方法(constructor)<br>4.1.3. 提供一个标识属性(identifier property)(可选) <br>4.1.4. 建议使用不是final的类 (可选)<br>4.2. 实现继承(Inheritance)<br>4.3. 实现equals()和hashCode()<br>4.4. 持久化生命周期(Lifecycle)中的回调(Callbacks)<br>4.5. 合法性检查(Validatable)回调<br>4.6. XDoclet标记示例<br>5. O/R Mapping基础<br>5.1. 映射声明(Mapping declaration)<br>5.1.1. Doctype<br>5.1.2. hibernate-mapping<br>5.1.3. class<br>5.1.4. id<br>5.1.4.1. generator<br>5.1.4.2. 高/低位算法(Hi/Lo Algorithm)<br>5.1.4.3. UUID算法(UUID Algorithm )<br>5.1.4.4. 标识字段和序列(Identity columns and Sequences)<br>5.1.4.5. 程序分配的标识符(Assigned Identifiers)<br>5.1.5. composite-id 联合ID<br>5.1.6. 识别器(discriminator)<br>5.1.7. 版本(version)(可选)<br>5.1.8. 时间戳(timestamp )(可选)<br>5.1.9. property<br>5.1.10. 多对一(many-to-one)<br>5.1.11. 一对一<br>5.1.12. 组件(component), 动态组件(dynamic-component)<br>5.1.13. 子类(subclass)<br>5.1.14. 连接的子类(joined-subclass)<br>5.1.15. map, set, list, bag<br>5.1.16. 引用(import)<br>5.2. Hibernate 的类型<br>5.2.1. 实体(Entities)和值(values)<br>5.2.2. 基本值类型<br>5.2.3. 持久化枚举(Persistent enum)类型<br>5.2.4. 自定义值类型<br>5.2.5. 映射到"任意"(any)类型<br>5.3. SQL中引号包围的标识符<br>5.4. 映射文件的模块化(Modular mapping files)<br>6. 集合类(Collections)映射<br>6.1. 持久化集合类(Persistent Collections)<br>6.2. 映射集合(Mapping a Collection)<br>6.3. 值集合和多对多关联(Collections of Values and Many-To-Many Associations)<br>6.4. 一对多关联(One-To-Many Associations)<br>6.5. 延迟初始化(延迟加载)(Lazy Initialization)<br>6.6. 集合排序(Sorted Collections)<br>6.7. 使用<idbag><br>6.8. 双向关联(Bidirectional Associations)<br>6.9. 三重关联(Ternary Associations)<br>6.10. 异类关联(Heterogeneous Associations)<br>6.11. 集合例子(Collection example)<br>7. 组件(Component)映射<br>7.1. 依赖对象(Dependent objects)<br>7.2. 在集合中出现的依赖对象<br>7.3. 组件作为Map的索引(Components as Map indices )<br>7.4. 组件作为联合标识符(Components as composite identifiers)<br>7.5. 动态组件 (Dynamic components)<br>8. 继承映射(Inheritance Mappings)<br>8.1. 三种策略<br>8.2. 限制<br>9. 操作持久化数据(Manipulating Persistent Data)<br>9.1. 创建一个持久化对象<br>9.2. 装载对象<br>9.3. Querying<br>9.3.1. 标量查询(Scalar query)<br>9.3.2. 查询接口(Query interface)<br>9.3.3. 可滚动迭代(Scrollable iteration)<br>9.3.4. 过滤集合类(Filtering collections)<br>9.3.5. 条件查询<br>9.3.6. 使用本地SQL的查询<br>9.4. 更新对象<br>9.4.1. 在同一Session中更新<br>9.4.2. 更新从session脱离的对象<br>9.4.3. 把与Session脱离的对象重新绑定<br>9.5. 删除持久化对象<br>9.6. 同步(Flush)<br>9.7. 结束一个Session<br>9.7.1. 同步(Flush) Session<br>9.7.2. 提交数据库事务<br>9.7.3. 关闭Session<br>9.7.4. 处理异常<br>9.8. 生命周期和对象图(Lifecyles and object graphs)<br>9.9. 拦截器(Interceptors)<br>9.10. 元数据(Metadata) API<br>10. 事务和并行(Transactions And Concurrency)<br>10.1. 配置,会话和工厂(Configurations, Sessions and Factories)<br>10.2. 线程和连接(Threads and connections)<br>10.3. 考虑对象辨别<br>10.4. 乐观并发控制(Optimistic concurrency control)<br>10.4.1. 使用长生命周期带有自动版本化的会话<br>10.4.2. 使用带有自动版本化的多个会话<br>10.4.3. 应用程序自己进行版本检查<br>10.5. 会话断开连接(Session disconnection)<br>10.6. 悲观锁定(Pessimistic Locking)<br>11. Hibernate查询语言(Query Language), 即HQL<br>11.1. 大小写敏感性(Case Sensitivity)<br>11.2. from 子句<br>11.3. 联合(Associations)和连接(joins)<br>11.4. select子句<br>11.5. 统计函数(Aggregate functions)<br>11.6. 多态(polymorphism)查询<br>11.7. where子句<br>11.8. 表达式(Expressions)<br>11.9. order by 子句<br>11.10. group by 子句<br>11.11. 子查询<br>11.12. HQL示例<br>11.13. 提示和技巧(Tips & Tricks)<br>12. 条件查询(Criteria Query)<br>12.1. 创建一个Criteria实例<br>12.2. 缩小结果集范围<br>12.3. 对结果排序<br>12.4. 关联(Associations)<br>12.5. 动态关联对象获取(Dynamic association fetching)<br>12.6. 根据示例查询(Example queries)<br>13. 原生SQL查询<br>13.1. 创建一个基于SQL的Query<br>13.2. 别名和属性引用<br>13.3. 为SQL查询命名<br>14. 性能提升(Improving performance)<br>14.1. 理解集合的性能<br>14.1.1. 分类<br>14.1.2. Lists, maps 和sets用于更新效率最高<br>14.1.3. Bag和list是反向集合类中效率最高的<br>14.1.4. 一次性删除(One shot delete)<br>14.2. 用于延迟装载的代理<br>14.3. 第二层缓存(The Second Level Cache)s<br>14.3.1. 对映射(Mapping)缓冲<br>14.3.2. 策略:只读缓存<br>14.3.3. 策略:读/写缓存<br>14.3.4. 策略:不严格的读/写缓存<br>14.3.5. 策略:事务缓存(transactional)<br>14.4. 管理Session缓存<br>14.5. 查询缓存(Query Cache)<br>15. 工具箱指南<br>15.1. Schema 生成器(Schema Generation)<br>15.1.1. 对schema定制化(Customizing the schema)<br>15.1.2. 运行该工具<br>15.1.3. 属性(Properties)<br>15.1.4. 使用Ant(Using Ant)<br>15.1.5. 对schema的增量更新(Incremental schema updates)<br>15.1.6. 用Ant来增量更新schema(Using Ant for incremental schema updates)<br>15.2. 代码生成(Code Generation)<br>15.2.1. 配置文件(可选)<br>15.2.2. meta属性<br>15.2.3. 基本的finder生成器(Basic finder generator)<br>15.2.4. 基于Velocity的渲染器/生成器(Velocity based renderer/generator)<br>15.3. 映射文件生成器(Mapping File Generation)<br>15.3.1. 运行此工具<br>16. 示例:父子关系(Parent Child Relationships)<br>16.1. 关于collections<br>16.2. 双向的一对多关系(Bidirectional one-to-many)<br>16.3. 级联生命周期(Cascading lifecycle)<br>16.4. 级联更新(Using cascading update())<br>16.5. 结论<br>17. 示例:Weblog 应用程序<br>17.1. 持久化类<br>17.2. Hibernate 映射<br>17.3. Hibernate 代码<br>18. 示例:不同的映射<br>18.1. 雇员/雇主(Employer/Employee)<br>18.2. 作者/著作(Author/Work)<br>18.3. 客户/订单/产品(Customer/Order/Product)<br>19. 最佳实践(Best Practices)。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值