我已经参数化了persistence.xml。我正在尝试使用hbm2ddl生成ddl schema。如何将参数传递给此工具?
我的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}"/>启动时,(使用-Dpersistence.dialect=value)将服务器参数值作为JAVA_OPTS传递。它工作得很好。
如何使用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}发布于 2010-03-04 06:53:52
您可以通过propertyfile指定方言。在hibernate.properties中声明它
hibernate.dialect=org.hibernate.dialect.Oracle9Dialect并像这样使用它:
<jpaconfiguration propertyfile="hibernate.properties"/>https://stackoverflow.com/questions/2371747
复制相似问题