問題描述
我正在開發一個新的 Oracle ADF 項目,該項目使用的是 Oragle 10g 數據庫,并且我在我們的項目中使用了 Unitils 和 DBMaintainer:
I am working on a new Oracle ADF project, that is using Oragle 10g Database, and I am using Unitils and DBMaintainer in our project for:
- 更新數據庫結構
- 單元測試
- 讀入種子數據
- 讀入測試數據
- 列表項
在我們的項目中,我們有 2 個架構,以及 2 個有權連接到這些架構的數據庫用戶.我將它們放在一個帶有增量名稱的文件夾結構中,并且我使用 @convention 進行腳本命名.
In our project, we have 2 schemas, and 2 db users that have privilegies to connect to these schemas. I have them in a folder structure with incremental names and I am using the @convention for script naming.
001_@schemaA_name.sql
002_@schemaB_name.sql
003_@schemaA_name.sql
這適用于 ant 和 DBMaintainer 更新任務,我通過為 ant 任務配置額外元素來提供多個用戶名.
This works fine with ant and DBMaintainer update task, and I supply the multiple user names by configuring extra elements for the ant task.
<target name="create" depends="users-drop, users-create" description="This tasks ... ">
<updateDatabase scriptLocations="${dbscript.maintainer.dir}" autoCreateDbMaintainScriptsTable="true">
<database name="${db.user.dans}" driverClassName="${driver}" userName="${db.user.dans}" password="${db.user.dans.pwd}" url="${db.url.full}" schemaNames="${db.user.dans}" />
<database name="idp" driverClassName="${driver}" userName="${db.user.idp}"
password="${db.user.idp.pwd}" url="${db.url.full}" schemaNames="${db.user.idp}" />
</updateDatabase>
</target>
但是,我不知道如何讓 DBMaintainer 更新任務從我的數據庫架構創建 xsd 架構?
However, I cant figure out, how to make the DBMaintainer update task create the xsd schemas from my db schemas?
所以,我決定使用 Unitils,因為它的更新創建了 xsd 模式.我還沒有找到有關 Unitils ant 任務的任何描述或文檔 - 任何人都可以提供一些提示嗎?目前,我想通過使用 @Dataset 注釋創建 Junit 測試來運行 Unitils.我可以讓它與一個模式和一個數據庫用戶一起工作.但我不知道如何讓它與多個用戶一起工作?
So, I decided to use Unitils, since its update creates xsd schemas. I haven't found any description or documentation for the Unitils ant tasks - can anyone give some hints? For the time being I have figured out to run Unitils by creating a Junit test, with @Dataset annotation. I can make it work with one schema, and one db user. But I am out of ideas how to make it work with multiple users?
這是我的 unitils-local.properties 設置:
Here is the unitils-local.properties setup I have:
database.url=jdbc\:oracle\:thin\:@localhost\:1521\:vipu
database.schemaNames=a,b
database.userName=a
database.password=a1
你們中的任何人都可以給我一個提示,如何讓 Unitils 與第二個用戶/模式一起工作??我將非常感謝您的幫助!
Can any of you guys give me a tip, how to make Unitils work with the second user/schema ?? I will be extremely gratefull for your help!
推薦答案
我已經弄清楚如何讓 dbmaintain 和 unitils 在多數據庫用戶支持上協同工作,但解決方案是純粹的 ant hack.
I have figure out how to make dbmaintain and unitils work together on multi-database-user support, but the solution is a pure ant hack.
- 我已經使用多數據庫用戶支持設置了 dbmaintain 的配置.
- 我制作了一個帶有用于替換的令牌密鑰的 unitils-local.properties 文件.
- 我的 ant 腳本的 init 目標是生成一個新的 unitils-local.properties 文件,通過將用戶名/密碼/模式的令牌替換為目標環境的正確值,然后將其復制到用戶主目錄.
- 我已將測試分類到以架構名稱為前綴的文件夾中
- 當 unitils 被調用時,它會選擇剛剛由 ant 腳本創建的 unitils-local.properties 文件,并發揮它的魔力.
它遠非漂亮,但它有效.
Its far from pretty, but it works.
這篇關于Unitils 和 DBMaintainer - 如何讓它們與多個用戶/模式一起工作?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!