zoukankan      html  css  js  c++  java
  • hibernate自动更新时方言问题

     hibernate.cfg.xml

     HTML Code 
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
     
    <?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">

    <!-- Generated by MyEclipse Hibernate Tools.                   -->
    <hibernate-configuration>

    <session-factory>
        <property name="dialect">
            <!-- org.hibernate.dialect.MySQLDialect -->
            org.hibernate.dialect.MySQL5Dialect
        </property>
        <property name="connection.url">
            jdbc:mysql://localhost:3306/test
        </property>
        <property name="connection.username">root</property>
        <property name="connection.password">root</property>
        <property name="connection.driver_class">
            com.mysql.jdbc.Driver
        </property>
        <property name="myeclipse.connection.profile">mysql</property>
        <property name="show_sql">ture</property>
        <property name="hbm2ddl.auto">update</property>
        <mapping resource="com/leejuen/hibernate/Student.hbm.xml" />

    </session-factory>

    </hibernate-configuration>

    在学习这里时按照书上打的使用了 
    <property name="hbm2ddl.auto">update</property>这个配置。这样会自动在mysql中建表。但实验时没有出现表。而是会出现没有test.student表的报错。但若是mysql中有这张表却会正常更新sql。其原因是应为mysql的方言设置问题。我的mysql用的是5以上的版本方言要设置成 org.hibernate.dialect.MySQL5Dialect 。这样就能正常使用。谢谢网友小笼包zzz。

    PS:还有博客中的代码高亮可以使用codeformat这个软件。是ACM的上古大牛做的很好用 
  • 相关阅读:
    docker常用命令
    docker安装注意事项
    DataGridView中实现自动编号
    Flask设置配置文件
    python路径找类并获取静态字段
    JavaScript数据类型
    php学习笔记6
    php学习笔记5
    php学习笔记4
    php学习笔记3
  • 原文地址:https://www.cnblogs.com/leejuen/p/5547485.html
Copyright © 2011-2022 走看看