Table not created with hbm2ddl.auto=update in Hibernate 5

*爱你&永不变心* 提交于 2019-12-05 10:34:25

We faced a similar problem after upgrading to Hibernate 5.x and this was solved by changing the dialect to org.hibernate.dialect.MySQL5Dialect.

Anas

try something like that in sessionFactoryInitialisation :

StandardServiceRegistry standardRegistry = new StandardServiceRegistryBuilder().configure(configFile).build();       
Metadata metadata =new MetadataSources(standardRegistry).getMetadataBuilder().build();  
sessionFactory = metadata.getSessionFactoryBuilder().build();
return sessionFactory;

add <property name="javax.persistence.schema-generation.database.action">create</property> in your hibernate config file.

The correct property name is: hibernate.hbm2ddl.auto

Docs: https://docs.jboss.org/hibernate/orm/5.0/manual/en-US/html/ch03.html#configuration-optional

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!