تمرير المعلمة إلى HBM2DDL
سؤال
لدي parametrived pressistence.xml. أحاول إنشاء مخطط DDL باستخدام HBM2DDL. كيف يمكنني نقل المعلمات إلى هذه الأداة؟
يبدو أن مثالتي. 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}
المحلول
يمكنك تحديد اللهجة عبر propertyfile
. أعلن ذلك في أ hibernate.properties
:
hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
واستخدمها مثل هذا:
<jpaconfiguration propertyfile="hibernate.properties"/>
لا تنتمي إلى StackOverflow