title: How to extract a subset of a database into a dbunit file using a sql query?
body: <h2>Why ?</h2>
  
  <p>I have got a big Oracle table. I would like to test some DAO methods. To do so, I use dbunit.</p>
  
  <h2>Problem</h2>
  
  <p>I would like to extract a subset of an existing database as a dbunit flat xml file using a sql query. Example of query : </p>
  
  <pre><code>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'
  </code></pre>
  
  <p>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.</p>
  
  <h2>What I've tried</h2>
  
  <ol>
  <li>Jailer</li>
  </ol>
  
  <p>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.</p>
  
  <ol>
  <li>DBUnit generation</li>
  </ol>
  
  <p>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.</p>
  
  <h2>Question</h2>
  
  <p>How to generate a subset of a database (and export it in a dbunit flat xml file) using a <strong>sql query</strong> as a base for the export ?</p>