2012-01-19 65 views
0

在我們的生產和開發中,我們針對MSSQL數據庫進行開發。在seam test中更改persistence.xml

但是當我們運行我們的測試時,我們想要對HSQL數據庫進行處理。

更改DS文件是沒有問題的,所以它對HSQL運行,但從persitence.xml中的舊dialce仍然是MSSQL方言,所以我如何將其更改爲HSQL方言?

// Trind

+0

是否使用Spring框架? – ruslan

+0

不,我使用Seam 2.2.2-Final,我們使用maven進行部署。 – Trind

回答

1

您可以使用資源和測試資源過濾。

<filters> 
    <filter>src/main/filters/dev.filter.properties</filter> 
    <filter>src/test/filters/dev.filter.properties</filter> 
</filters> 
<resources> 
    <resource> 
     <directory>src/main/resources</directory> 
     <filtering>true</filtering> 
    </resource> 
</resources> 
<testResources> 
    <testResource> 
     <directory>src/test/resources</directory> 
     <filtering>true</filtering> 
    </testResource> 
</testResources> 

在dev.filter.properties文件定義hibernate.dialet屬性,使其在主測試目錄不同。

然後使用它在test和main中的persistence.xml文件。

http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html

http://maven.apache.org/plugins/maven-resources-plugin/testResources-mojo.html

+0

當我有不同的測試項目和正在測試的項目時,這是否工作? – Trind

+1

如果你有2個獨立的項目,那麼你可以使用兩個單獨的persistence.xml文件,每個文件都包含它的方言。 – dcernahoschi

相關問題