首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将参数传递给hbm2ddl

将参数传递给hbm2ddl
EN

Stack Overflow用户
提问于 2010-03-03 21:47:17
回答 1查看 1.9K关注 0票数 2

我已经参数化了persistence.xml。我正在尝试使用hbm2ddl生成ddl schema。如何将参数传递给此工具?

我的persistence.xml看起来像

代码语言:javascript
复制
<property name="hibernate.connection.driver_class" value="${persistence.connection.driver.class}"/>
<property name="hibernate.dialect" value="${persistence.dialect}"/>
<property name="hibernate.connection.password" value="${persistence.password}"/>
<property name="hibernate.connection.username" value="${persistence.username}"/>

启动时,(使用-Dpersistence.dialect=value)将服务器参数值作为JAVA_OPTS传递。它工作得很好。

如何使用hbm2ddl实现这一点?

我试过房地产

代码语言:javascript
复制
<hibernatetool destdir="${gensrc.sql.dir}">
  <property key="persistence.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
  <jpaconfiguration persistenceunit="${persistence.unit.name}" />
  <classpath>
   <!-- it is in this classpath you put your classes dir,
       and/or jpa persistence compliant jar -->
    <path location="${build.classes.dir}" />
  </classpath>
  <hbm2ddl export="false" drop="true" outputfilename="create_${ant.project.name}.sql" format="true" haltonerror="true" />
</hibernatetool>

但是它不会得到这个值。它显示了我的错误。

代码语言:javascript
复制
build.xml:160: org.hibernate.HibernateException: Dialect class not found: ${persistence.dialect}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-03-04 06:53:52

您可以通过propertyfile指定方言。在hibernate.properties中声明它

代码语言:javascript
复制
hibernate.dialect=org.hibernate.dialect.Oracle9Dialect

并像这样使用它:

代码语言:javascript
复制
<jpaconfiguration propertyfile="hibernate.properties"/>
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2371747

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档