我正在使用 Hibernate 租赁,每次用户登录时,我都会将数据库更改为他的用户名 (SQLite)。遗憾的是,有时数据库不存在,我需要创建它。
问题是我不知道如何在运行时在数据库中创建所有表。
通常 Hibernete 会用这个为我创建数据库:
<property name="hibernate.hbm2ddl.auto">update</property>
最佳答案
您是否尝试使用 create
值。
A value of create will create your tables at sessionFactory creation, and leave them intact.
A value of create-drop will create your tables, and then drop them when you close the sessionFactory.
应该是
<property name="hibernate.hbm2ddl.auto">create</property>
更多信息here和 here
或者可能有一个 dialect problem
关于java - 如何在运行时在 Hibernate 中创建数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16801941/