hbm2ddlにパラメータを渡します
質問
私はpersistence.xmlのをパラメータ化しています。私はhbm2ddlを使用してDDLスキーマを生成しようとしています。どのように私は、このツールにパラメータを渡すことができますか?
タグのような私の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}"/>
iは、サーバー・パラメータ値は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}
解決
あなたはpropertyfile
経由で方言を指定することができます。 hibernate.properties
でそれを宣言します:
hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
そして、このようにそれを使用します:
<jpaconfiguration propertyfile="hibernate.properties"/>
所属していません StackOverflow