zoukankan      html  css  js  c++  java
  • Hibernate----配置文件Hibernate.cfg.xml

    在Hibernate中大配置一般命名为“HIbernate.cfg.xml”

      Hibernate配置文件主要用于配置数据库连接和HIbernate运行时所需要的各种特性。

    <?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>
            <!-- 数据库JDBC驱动 -->
            <property name="connection.driver_class">oracle.jdbc.OracleDriver</property>
            <!-- 数据库URL -->
            <property name="connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>
            <!-- 数据库用户名 -->
            <property name="connection.username">szj</property>
            <!-- 数据库密码 -->
            <property name="connection.password">szj</property>
            <!-- 方言 -->
            <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
            
            <!-- 输出所有sql语句到控制台 -->
            <property name="hibernate.show_sql">true</property>
            
            <!-- 在 log 和 conlose 中打印出更漂亮SQL -->
            <property name="hibernate.format_sql">true</property>
            
            <!-- hbm2ddl  -->
            <property name="hibernate.hbm2ddl.auto">update</property>
            
            <!-- 指定当前session范围和上下文 thread指当前线程来跟踪管理 -->
            <property name="current_session_context_class">thread</property>
            <!-- 映射文件配置,注意配置文件名必须包含其相对于classpath的全路径 -->
            <mapping resource="cn/happy/entity/Student.hbm.xml"/>
            
        </session-factory>
        
    </hibernate-configuration>
  • 相关阅读:
    Springboot(一)springboot简介与入门程序
    Java基础(二)流程语句与数组
    Java基础(一)基础常识
    Kubernetes介绍
    K8s 存储
    Kubernetes 集群组件
    Kubernetes 设计理念
    Kubernetes 部署与实战
    容器技术与资源隔离
    Docker 网络配置
  • 原文地址:https://www.cnblogs.com/szj-ang/p/HIbernate.html
Copyright © 2011-2022 走看看