設定hibernate.hbm2ddl.auto屬性後,每次測試都tables doesn't exist的解決辦法
阿新 • • 發佈:2019-02-13
初學hibernate,發現這個hibernate.hbm2ddl.auto的屬性很蛋疼,設定該屬性後,無論是=create 還是=update,每次執行Junit測試執行程式碼的時候總會最後報個錯---tables doesn't exist!
蛋疼了一會,慢慢debug,發現它的確是很聽話的把表給刪除了,但是在hibernate往mysql裡寫建表語句的時候,就會報錯建表失敗,並且還說hibernate的mysql語法有問題,又檢查了一下hibernate自動生成的建表語句,覺得會不會是版本的問題,於是乎想到了這裡:
<!--hibernate.dialect 只是Hibernate使用的資料庫方言,就是要用Hibernate連線那種型別的資料庫伺服器。--> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect </property>
then ,就把它改成了:
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect </property>
然後,我就去島國動作片了。。。。