Unitils 和 DBMaintainer - 如何使它们与多个用户/模式一起工作?
我正在开发一个新的 Oracle ADF 项目,该项目使用 Oragle 10g 数据库,并且我在我们的项目中使用 Unitils 和 DBMaintainer 来执行以下操作:
- 更新数据库结构
- 单元测试
- 读取种子数据
- 读取测试数据
- 列表项
在我们的项目中,我们有2 个架构,以及 2 个有权连接到这些架构的数据库用户。我将它们放在具有增量名称的文件夹结构中,并且我使用 @convention 进行脚本命名。
001_@schemaA_name.sql
002_@schemaB_name.sql
003_@schemaA_name.sql
这适用于 ant 和 DBMaintainer 更新任务,并且我通过为 ant 任务配置额外元素来提供多个用户名。
<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 模式?
因此,我决定使用 Unitils,因为它的更新创建了 xsd 模式。 我还没有找到有关 Unitils ant 任务的任何描述或文档 - 谁能给出一些提示? 目前,我已经想出通过创建带有 @Dataset 注释的 Junit 测试来运行 Unitils。我可以让它与一种模式和一个数据库用户一起使用。但我不知道如何让它与多个用户一起工作?
这是我的unitils-local.properties 设置:
database.url=jdbc\:oracle\:thin\:@localhost\:1521\:vipu
database.schemaNames=a,b
database.userName=a
database.password=a1
你们中的任何人都可以给我一个提示,如何使Unitils 与第二个用户/模式一起工作? 我将非常感谢您的帮助!
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:
- updating the db structure
- unittesting
- read in seed data
- read in test data
- List item
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
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>
However, I cant figure out, how to make the DBMaintainer update task create the xsd schemas from my db schemas?
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?
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
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
最终我找到了一种方法来注入您选择的任何unitil.properties——通过自己实例化Unitils!
您需要一个调用 @BeforeClass 的方法,在其中执行如下操作:
我根据加载的 hibernate 配置(通过 @HibernateSessionFactory)选择属性文件,但还应该有其他选项
eventually I found a way to inject any unitil.properties of your choice --- by instantiating Unitils yourself!
You need a method that is evoked @BeforeClass, in which you perform something like the following:
I choose the properties file depending on which hibernate configuration is loaded (via @HibernateSessionFactory), but there should be other options as well
我已经弄清楚如何使 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.
Its far from pretty, but it works.
查看此链接:http://www.dbmaintain.org/tutorial.html#From_Java_code
具体来说,您可能需要执行以下操作:
此外,此链接可能会有所帮助:http:// www.dbmaintain.org/tutorial.html#Multi-database__user_support
Check out this link: http://www.dbmaintain.org/tutorial.html#From_Java_code
Specifically you may need to do something like:
Also this link may be helpful: http://www.dbmaintain.org/tutorial.html#Multi-database__user_support
我听从了瑞安的建议。当我调试 UnitilsDB 时,我注意到一些变化。
以下是我正在运行的 unitils-local.properties:
确保使用 @ConfigurationProperties(prefix = "database.db1") 连接到测试用例中的特定数据库:
I followed Ryan suggestion. I noticed couple changes when I debugged UnitilsDB.
Following is my running unitils-local.properties:
Make sure to use @ConfigurationProperties(prefix = "database.db1") to connecto to particular database in your test case: