问题描述
我有一个很大的Oracle桌子.我想测试一些DAO方法.为此,我使用dbunit.
I have got a big Oracle table. I would like to test some DAO methods. To do so, I use dbunit.
我想使用sql查询将现有数据库的子集提取为dbunit flat xml文件.查询示例:
I would like to extract a subset of an existing database as a dbunit flat xml file using a sql query. Example of query :
Select
t1.field1 as field1, t1.field2 as field2, t2.field3 as field3
From
table1 t1
Join table2 t2 on t1.fieldX=t2.fieldX
Where
t1.field6='value' and t2.field8='value2'
在这种情况下,它将提取作为查询结果的table1和table2的所有记录,然后还提取这些记录的所有依赖项.
in this case it will extract all records of table1 and table2 which are results of the query and then it also extract all dependencies of these records.
- 狱卒
我已经测试了Jailer,它是一个很好的工具.问题是我只能对一个表进行查询并提取保持关系的查询.我的sql查询具有多个联接,并且使用此软件无法解决其中的条件.
I've tested Jailer which is a good tool. The problem is that I can only do a query on one table and extract it keeping relations. My sql query have several joins and where conditions that cannot be resolve using this software.
- DBUnit生成
我也尝试过直接使用DBUnit来生成数据集,但是它需要大量工作,因为我们不能直接从sql查询中生成子集,而只能通过在每个表上指定一系列小的查询来生成.我有很多人加入,并且在哪里有条件,所以这不是可接受的解决方案.
I've also tried to use DBUnit directly to generate the dataset but it need a lot of work because we cannot generate a subset from a sql query directly but only by specifiyng a succession of little queries on each table.I've got lot of joins and where conditions so it's not an acceptable solutions.
如何使用 sql查询作为导出的基础来生成数据库的子集(并将其导出到dbunit flat xml文件中)?
How to generate a subset of a database (and export it in a dbunit flat xml file) using a sql query as a base for the export ?
推荐答案
我认为您想要的东西可能超出了DBUnit的权限.
I think what you want might be outside of the purview of DBUnit.
我认为最好的方法是设置一系列处理联接的视图,并通过该视图提取数据.拥有视图后,就可以使用SQL查询将数据拉出.
What I think the best way to do this is to set-up a series of views which handle the joins and pull your data out through that. Once you have your views you can use SQL queries to pull the data out.
这篇关于如何使用SQL查询将数据库的子集提取到dbunit文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!