你好我在執行hibernate
,當我試圖插入新記錄獲得異常org.hibernate.exception.sqlgrammarexception
獲取例外:org.hibernate.exception.sqlgrammarexception
我hibernate.cfg.xml
文件:
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernate_db</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">system</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="hbm2ddl.auto">create</property>
<mapping class="com.hib.UserDetails"/>
</session-factory>
</hibernate-configuration>
如果我改變
<property name="hbm2ddl.auto">update</property>
<mapping class="com.hib.UserDetails"/>
它的工作,但我必須手動創建表。 可能是什麼問題?
我的建議是不用專門選擇方言,除非你100%確保你選擇是正確的。 Hibernate非常擅長確定連接到的數據庫類型。如果您需要更多幫助,則需要在發生異常的地方發佈代碼。 – JamesENL