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的上古大牛做的很好用 
  • 相关阅读:
    django大全
    centos 下安装python3.6.2
    爬虫基础知识与简单爬虫实现
    HDU5950 Recursive sequence (矩阵快速幂加速递推) (2016ACM/ICPC亚洲赛区沈阳站 Problem C)
    ZOJ5833 Tournament(递归打表)
    ZOJ4067 Books(贪心)
    ZOJ4062 Plants vs. Zombies(二分+贪心)
    ZOJ4060 Flippy Sequence(思维题)
    洛谷P2568 GCD(线性筛法)
    2018.11.6刷题记录
  • 原文地址:https://www.cnblogs.com/leejuen/p/5547485.html
Copyright © 2011-2022 走看看