Unitils 和 DBMaintainer - 如何让它们与多个用户/模式一起工作? [英] Unitils and DBMaintainer - how to make them work with multiple users/schemas?

查看:30
本文介绍了Unitils 和 DBMaintainer - 如何让它们与多个用户/模式一起工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个新的 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.

  1. 我已经使用多数据库用户支持设置了 dbmaintain 的配置.
  2. 我制作了一个带有用于替换的令牌密钥的 unitils-local.properties 文件.
  3. 我的 ant 脚本的 init 目标是生成一个新的 unitils-local.properties 文件,通过将用户名/密码/模式的令牌替换为目标环境的正确值,然后将其复制到用户主目录.
  4. 我已将测试分类到以架构名称为前缀的文件夹中
  5. 当 unitils 被调用时,它会选择刚刚由 ant 脚本创建的 unitils-local.properties 文件,并发挥它的魔力.

它远非漂亮,但它有效.

Its far from pretty, but it works.

这篇关于Unitils 和 DBMaintainer - 如何让它们与多个用户/模式一起工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆