Java 如何使Hibernate创建用于初始化和更新的数据库SQL脚本
Hibernate能够创建数据库结构。下面是使用Java 如何使Hibernate创建用于初始化和更新的数据库SQL脚本,java,sql,hibernate,initialization,Java,Sql,Hibernate,Initialization,Hibernate能够创建数据库结构。下面是使用 (在本例中使用Hibernate实体管理器) org.hibernate.ejb.HibernatePersistence 如何使Hibernate创建用于初始化和更新的数据库SQL脚本?(可以手动运行,也可以通过批处理执行)以及用于此操作的工具 是的,log(Q)中有SQL语句,但这不是干净的解决方案 我们的目标是为每个版本的自动数据库升级准备解决方案。对于自动数据库升级,请查看另一个专门为该工作设计的工具。我建议 通常,管理员手动执行SQ
(在本例中使用Hibernate实体管理器)
org.hibernate.ejb.HibernatePersistence
如何使Hibernate创建用于初始化和更新的数据库SQL脚本?(可以手动运行,也可以通过批处理执行)以及用于此操作的工具
是的,log(Q)中有SQL语句,但这不是干净的解决方案
我们的目标是为每个版本的自动数据库升级准备解决方案。对于自动数据库升级,请查看另一个专门为该工作设计的工具。我建议 通常,管理员手动执行SQL命令。让他学习新的东西只是为了用另一种方式做事,这是一个死主意。方法应该是自动化。我不知道是否适用
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<!-- value="create" to build a new database on each run; value="update" to modify an existing database; value="create-drop" means the same as "create" but also drops tables when Hibernate closes; value="validate" makes no changes to the database -->
<property name="hibernate.hbm2ddl.auto" value="create"/>
<property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/>
<property name="hibernate.connection.charSet" value="UTF-8"/>
<!-- Uncomment the following two properties for JBoss only -->
<!-- property name="hibernate.validator.apply_to_ddl" value="false" /-->
<!-- property name="hibernate.validator.autoregister_listeners" value="false" /-->
</properties>
</persistence-unit>
</persistence>