[英]How can I recreate my database with hibernate pojo files
I lost my projects' database from my pc. 我从我的电脑上丢失了项目的数据库。 But I have my JSP project which includes hibernate.
但是我有包含休眠的JSP项目。 Whenever I run the project it says ' org.hibernate.exception.SQLGrammarException: Cannot open connection ' because the database not exist in the server.
每当我运行该项目时,它都会显示“ org.hibernate.exception.SQLGrammarException:无法打开连接 ”,因为服务器中不存在该数据库。 Can I recreate my database with the help of the POJO files?
我可以在POJO文件的帮助下重新创建数据库吗? I am using netbeans and MySQL server 5.1
我正在使用netbeans和MySQL服务器5.1
Yes you can recreate your database using hibernate. 是的,您可以使用休眠方式重新创建数据库。 In our session factory you need to set the following property.
在我们的会话工厂中,您需要设置以下属性。
<property name="jpaProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">create</prop>
</props>
</property>
hibernate.hbm2ddl.auto
Automatically validate or exports schema DDL to the database when the SessionFactory is created hibernate.hbm2ddl.auto
创建SessionFactory时自动将架构DDL验证或导出到数据库
There are a couple of caveats you need to understand: 您需要了解以下几点警告:
This will at least get you back up with a majority of what you lost at the very least. 这至少会使您至少损失了大部分损失。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.