【hibernate】hibernate框架配置详解

1 元数据配置文件详解

TbBrandEntity.hbm.xml






<hibernate-mapping>

    

    <class name="cn.itcast.domain.TbBrandEntity" table="tb_brand" schema="pinyougoudb">

        

        <id name="id" column="id"/>
        
        <property name="name" column="name"/>
        <property name="firstChar" column="first_char"/>
    class>
hibernate-mapping>



主配置文件hibernate.cfg.xml



<hibernate-configuration>
  <session-factory>
    
    <property name="connection.url">jdbc:mysql://localhost:3306/pinyougoudb?serverTimezone=UTCproperty>
    
    <property name="connection.driver_class">com.mysql.cj.jdbc.Driverproperty>
    
    <property name="hibernate.connection.username">rootproperty>
    
    <property name="hibernate.connection.password">rootproperty>
    
    <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialectproperty>

    
    <property name="hibernate.show_sql">trueproperty>
    
    <property name="hibernate.format_sql">trueproperty>



      <mapping class="cn.itcast.domain.TbBrandEntity"/>
      <mapping resource="cn/itcast/domain/TbBrandEntity.hbm.xml"/>

      
    
  session-factory>
hibernate-configuration>

你可能感兴趣的:(▶5)数据库,hibernate)