Hibernate5的hibernate.cfg.xml基本配置

来源:互联网 发布:软件开发图片 编辑:程序博客网 时间:2024/05/20 23:58
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE hibernate-configuration PUBLIC        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"><hibernate-configuration>    <session-factory>        <!-- DB连接四要素 -->        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernate5</property>        <property name="hibernate.connection.username">root</property>        <property name="hibernate.connection.password">root</property>        <!-- 方言 -->        <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>        <!--C3P0 数据源(数据库连接池) -->        <!--<property name="hibernate.connection.provider_class">org.hibernate.c3p0.internal.C3P0ConnectionProvider</property>-->        <!-- 当前Session上下文 -->        <property name="hibernate.current_session_context_class">thread</property>        <!-- 自动建表 -->        <property name="hibernate.hbm2ddl.auto">update</property>        <!-- 显示SQL -->        <property name="hibernate.show_sql">true</property>        <!-- 格式化SQL -->        <property name="hibernate.format_sql">true</property>        <!-- 注册映射文件 -->        <!--<mapping resource="com/luo/beans/Student.hbm.xml"/>-->        <!--package参数无法确定怎么用,知道的朋友可留言-->        <mapping package="domain"/>        <mapping class="domain.Event"/>    </session-factory></hibernate-configuration>