2
我有参数化persistence.xml。我正在尝试使用hbm2ddl生成ddl模式。我怎样才能将参数传递给这个工具?将参数传递给hbm2ddl
我的persistence.xml看起来像
<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}"/>
当启动服务器参数值作为JAVA_OPTS传递(使用-Dpersistence.dialect =值)。它运作良好。
我如何用hbm2ddl做到这一点?
我试图财产
<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>
但是它没有得到这个值。它显示我错误。
build.xml:160: org.hibernate.HibernateException: Dialect class not found: ${persistence.dialect}
感谢帕斯卡。我指的是https://www.hibernate.org/hib_docs/tools/reference/en/html/ant.html 我如何使用蚂蚁做到这一点?我的意思是你能指出我在哪里我应该在中指定这些属性 谢谢。 –
2010-03-04 12:30:09
@Jigar抱歉,错误的链接。我已经更新了与其他人的建议。 – 2010-03-04 14:59:16
再次感谢。有效。 (第一)。 (jpa配置不支持prop属性。) 小问题仍然存在。使参数化persistence.xml的目的是在运行时更改此值。所以如果想为oracle生成ddl,我可以用方言指定一个参数,并生成ddl。在这里我必须用hibernate.dialect = oracle.driver指定一个文件。我现在已经完成了这个工作。感谢您的回复。 – 2010-03-08 13:57:05