我在阿里云上安裝了mysql 版本號是 5.7.30=0ubuntu0.18.04.1
然后在hibernate.hbm.xml 的組態檔中配置的 <property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
常見的MySQL5InnoDBDialect,MySQL5Dialect,MySQL57Dialect,MySQL57InnoDBDialect 都嘗試過了,但是依然存在下面的警告,程式能正常運行,也能正常插入結果。
WARN: GenerationTarget encountered exception accepting command : Error executing DDL "alter table product_ add constraint FK5g0v39gl73bdiw9waaha0pkfg foreign key (category) references category_ (id)" via JDBC Statement
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table product_ add constraint FK5g0v39gl73bdiw9waaha0pkfg foreign key (category) references category_ (id)" via JDBC Statement
uj5u.com熱心網友回復:
參考 樓主 云上行者Gorge 的回復: 我在阿里云上安裝了mysql 版本號是 5.7.30=0ubuntu0.18.04.1
然后在hibernate.hbm.xml 的組態檔中配置的 <property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
常見的MySQL5InnoDBDialect,MySQL5Dialect,MySQL57Dialect,MySQL57InnoDBDialect 都嘗試過了,但是依然存在下面的警告,程式能正常運行,也能正常插入結果。
WARN: GenerationTarget encountered exception accepting command : Error executing DDL "alter table product_ add constraint FK5g0v39gl73bdiw9waaha0pkfg foreign key (category) references category_ (id)" via JDBC Statement
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table product_ add constraint FK5g0v39gl73bdiw9waaha0pkfg foreign key (category) references category_ (id)" via JDBC Statement
配置中添加一下試試
<property name="hbm2ddl.auto">update</property>
uj5u.com熱心網友回復:
參考 1 樓 qq_39936465 的回復: Quote: 參考 樓主 云上行者Gorge 的回復: 我在阿里云上安裝了mysql 版本號是 5.7.30=0ubuntu0.18.04.1
然后在hibernate.hbm.xml 的組態檔中配置的 <property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
常見的MySQL5InnoDBDialect,MySQL5Dialect,MySQL57Dialect,MySQL57InnoDBDialect 都嘗試過了,但是依然存在下面的警告,程式能正常運行,也能正常插入結果。
WARN: GenerationTarget encountered exception accepting command : Error executing DDL "alter table product_ add constraint FK5g0v39gl73bdiw9waaha0pkfg foreign key (category) references category_ (id)" via JDBC Statement
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table product_ add constraint FK5g0v39gl73bdiw9waaha0pkfg foreign key (category) references category_ (id)" via JDBC Statement
配置中添加一下試試
<property name="hbm2ddl.auto">update</property>配置中添加這個了,沒有作用
uj5u.com熱心網友回復:
參考 2 樓 云上行者Gorge 的回復: Quote: 參考 1 樓 qq_39936465 的回復: 配置中添加這個了,沒有作用
感覺hibernate配置應該沒問題,是你的sql陳述句有問題吧! 把sql貼一下看看。
uj5u.com熱心網友回復:
SQL陳述句是自動生成的
SessionFactory sf = new Configuration().configure().buildSessionFactory();
Session s = sf.openSession();
s.beginTransaction();
Category c = new Category();
//c.setId(1);
c.setName("c6");
s.save(c);
Product p = (Product)s.get(Product.class,4);
p.setCategory(c);
s.update(p);
s.getTransaction().commit();
s.close();
sf.close();
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/256536.html
標籤:Java相關
上一篇:為什么PriorityQueue用陣列實作?
下一篇:控制元件使用例外:component must be showing on the screen to determine its location