Hibernate配置文件模板(.cfg.xml)
 
 
下面是我写的一个hibernate3.x.x配置文件,使用的是JDBC链接配置。是结合XDoclet生成Hibernate映射文件和sql脚本例子中的hibernate配置。此文件可以作为模板来用,我常常查看。
 
<?xml version='1.0' encoding='gb2312'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <!--显示执行的SQL语句-->
        <property name="show_sql">true</property>
        <!--连接字符串-->
        <property name="connection.url">jdbc:mysql://localhost:3306/zfvims</property>
        <!--连接数据库的用户名-->
        <property name="connection.username">zfvims</property>
        <!--数据库用户密码-->
        <property name="connection.password">leizhimin</property>
        <!--数据库驱动-->
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <!--JDBC连接池(使用内置的连接池)-->
        <property name="connection.pool_size">1</property>
        <!--设置Hibernate自动管理上下文的策略-->
        <property name="current_session_context_class">thread</property>
        <!--选择使用的方言-->
        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
        <!--在启动时删除并重新创建数据库-->
        <property name="hbm2ddl.auto">create</property>
        <mapping resource="events/Event.hbm.xml"/>
        <mapping resource="events/Person.hbm.xml"/>
    </session-factory>
</hibernate-configuration>