6
我有一個管理3個數據庫的應用程序。我在縫框架上使用了JPA的hibernate。休眠/ JPA:映射實體到不同的數據庫
所以我有像這三persitence單元中的persitence.xml文件(我刪除屬性爲DB2和DB3):
<persistence-unit name="db1" transaction-type="JTA" >
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>db1source</jta-data-source>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.connection.driver_class"
value="oracle.jdbc.driver.OracleDriver" />
<property name="hibernate.hbm2ddl.auto" value="validate" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.default_schema" value="SI_TEC" />
<property name="hibernate.validator.apply_to_ddl" value="false" />
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.WeblogicTransactionManagerLookup" />
</properties>
</persistence-unit>
<persistence-unit name="db2" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>d2source</jta-data-source>
</persistence-unit>
<persistence-unit name="db3" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>d3source</jta-data-source>
</persistence-unit>
在我縫的components.xml文件,我創建3個管理的持久性-context將接縫與我的休眠配置進行映射。
最後,我有幾個實體,我的問題在這裏。我需要在db2中保留一些實體,並在db3中保留其他實體。因此,數據庫架構是不同的,當我部署我的應用程序,我得到這個錯誤:
org.hibernate.HibernateException: Missing table: PORTAILPERMISSION
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1113)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:139)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:349)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
Truncated. see log file for complete stacktrace
因爲,表PORTAILPERMISSION不存在的DB2。
我的問題是:
如何指定實體類哪個數據庫(或persitence單位)必須使用在啓動驗證實體?
感謝您的幫助。
如何關閉自動檢測功能? – Kiva 2010-08-18 10:33:38
@Kiva看到我的更新 – Bozho 2010-08-18 10:44:31
謝謝,我加了這個,所有的工作好:) – Kiva 2010-08-18 10:45:32