org.dbunit.database
Class QueryDataSet

java.lang.Object
  extended by org.dbunit.dataset.AbstractDataSet
      extended by org.dbunit.database.QueryDataSet
All Implemented Interfaces:
IDataSet

public class QueryDataSet
extends AbstractDataSet

Holds collection of tables resulting from database query.

Since:
Dec 4, 2002
Version:
$Revision: 912 $ $Date: 2008-12-06 10:01:42 -0600 (Sat, 06 Dec 2008) $
Author:
Eric Pugh, gommma, Last changed by: $Author: gommma $

Field Summary
 
Fields inherited from class org.dbunit.dataset.AbstractDataSet
_orderedTableNameMap
 
Constructor Summary
QueryDataSet(IDatabaseConnection connection)
          Create a QueryDataSet by passing in the connection to the database to use.
QueryDataSet(IDatabaseConnection connection, boolean caseSensitiveTableNames)
          Create a QueryDataSet by passing in the connection to the database to use.
 
Method Summary
 void addTable(String tableName)
          Adds a table with using 'SELECT * FROM tableName' as query.
 void addTable(String tableName, String query)
          Adds a table and it's associated query to this dataset.
protected  ITableIterator createIterator(boolean reversed)
          Creates an iterator which provides access to all tables of this dataset
 String[] getTableNames()
          Returns names of tables in this dataset in proper sequence.
 
Methods inherited from class org.dbunit.dataset.AbstractDataSet
createTableNameMap, getTable, getTableMetaData, getTables, isCaseSensitiveTableNames, iterator, reverseIterator, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QueryDataSet

public QueryDataSet(IDatabaseConnection connection)
Create a QueryDataSet by passing in the connection to the database to use.

Parameters:
connection - The connection object to the database.

QueryDataSet

public QueryDataSet(IDatabaseConnection connection,
                    boolean caseSensitiveTableNames)
Create a QueryDataSet by passing in the connection to the database to use.

Parameters:
connection - The connection object to the database.
caseSensitiveTableNames - Whether or not this dataset should use case sensitive table names
Since:
2.4.2
Method Detail

addTable

public void addTable(String tableName,
                     String query)
              throws AmbiguousTableNameException
Adds a table and it's associated query to this dataset.

Parameters:
tableName - The name of the table
query - The query to retrieve data with for this table. Can be null which will select all data (see addTable(String) for details)
Throws:
AmbiguousTableNameException

addTable

public void addTable(String tableName)
              throws AmbiguousTableNameException
Adds a table with using 'SELECT * FROM tableName' as query.

Parameters:
tableName - The name of the table
Throws:
AmbiguousTableNameException

createIterator

protected ITableIterator createIterator(boolean reversed)
                                 throws DataSetException
Description copied from class: AbstractDataSet
Creates an iterator which provides access to all tables of this dataset

Specified by:
createIterator in class AbstractDataSet
Parameters:
reversed - Whether the created iterator should be a reversed one or not
Returns:
The created ITableIterator
Throws:
DataSetException

getTableNames

public String[] getTableNames()
                       throws DataSetException
Description copied from interface: IDataSet
Returns names of tables in this dataset in proper sequence. Multiple occurrence of the same name may be returned if multiple tables having the same name are present in the dataset.

Specified by:
getTableNames in interface IDataSet
Overrides:
getTableNames in class AbstractDataSet
Throws:
DataSetException


Copyright © 2002-2012. All Rights Reserved.