public class QuerySet
extends org.apache.tools.ant.ProjectComponent
In our database we have INDIVIDUALS which must have an associated NAME_INFO and at least one IND_ADDRESS. The developer creating a dataset for his/her tests probably won't know all the details of what relationships are expected, and if he did, its an error prone and repetitive task to create the correct SQL for entities in each dataset. Missing a related table, not only creates invalid data for your tests, but also is likely to cause DBUnit setUp() failures from foreign key constraint violation errors. (example: If a previous test had inserted INDIVIDUALS and NAME_INFO and my test tries to delete only the INDIVIDUALS, the NAME_INFO.IND_ID constraint would be violated)
 Each queryset is internally converted to a QueryDataSet and then
 combined using a CompositeDataSet. This means that you can use
 more than one query element for any given table provided they
 are nested within separate querysets.
 
Usage:
 <!-- ======== Define the reusable reference ========== -->
 <queryset id="individuals">
    <query name="INDIVIDUALS" sql="
      SELECT * FROM INDIVIDUALS WHERE IND_ID IN (@subQuery@)"/>
    <query name="NAME_INFO" sql="
      SELECT B.* FROM INDIVIDUALS A, NAME_INFO B
      WHERE A.IND_ID IN (@subQuery@)
      AND B.IND_ID = A.IND_ID"/>
    <query name="IND_ADDRESSES" sql="
      SELECT B.* FROM INDIVIDUALS A, IND_ADDRESSES B
      WHERE A.IND_ID IN (@subQuery@)
      AND B.IND_ID = A.IND_ID"/>
 </queryset>
 <!-- ========= Use the reference ====================== -->
 <dbunit driver="${jdbcDriver}"
     url="${jdbcURL}" userid="${jdbcUser}" password="${jdbcPassword}">
   <export dest="${dest}">
   <queryset refid="individuals">
      <filterset>
        <filter token="subQuery" value="
          SELECT IND_ID FROM INDIVIDUALS WHERE USER_NAME = 'UNKNOWN'"/>
      </filterset>
   </queryset>
   </export>
 </dbunit>
 | Constructor and Description | 
|---|
QuerySet()  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
addFilterSet(org.apache.tools.ant.types.FilterSet filterSet)  | 
void | 
addQuery(Query query)  | 
void | 
copyQueriesFrom(QuerySet referenced)  | 
String | 
getId()  | 
List | 
getQueries()  | 
QueryDataSet | 
getQueryDataSet(IDatabaseConnection connection)  | 
String | 
getRefid()  | 
void | 
setId(String string)  | 
void | 
setRefid(String string)  | 
public void addQuery(Query query)
public void addFilterSet(org.apache.tools.ant.types.FilterSet filterSet)
public String getId()
public String getRefid()
public void setId(String string) throws org.apache.tools.ant.BuildException
org.apache.tools.ant.BuildExceptionpublic void setRefid(String string) throws org.apache.tools.ant.BuildException
org.apache.tools.ant.BuildExceptionpublic List getQueries()
public void copyQueriesFrom(QuerySet referenced)
public QueryDataSet getQueryDataSet(IDatabaseConnection connection) throws SQLException, AmbiguousTableNameException
Copyright © 2002–2025. All rights reserved.