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的上古大牛做的很好用 
  • 相关阅读:
    windows下Redis安装及使用
    DQL、DML、DDL、DCL的概念与区别
    成长路上破局思维:工具化时间管理
    git push 本地分支与远程分支关联
    vue elementUI table表格列动态渲染的案例
    flutter 页面频繁刷新节省页面性能的组件RepaintBoundary
    elementUI Table表格表头自定义
    vue 项目添加echarts图表
    flutter 高斯实现模糊
    flutter 监听软键盘的弹出和关闭
  • 原文地址:https://www.cnblogs.com/leejuen/p/5547485.html
Copyright © 2011-2022 走看看