From: <man...@oz...> - 2004-02-19 15:34:34
|
--------------- On 02/19/2004 04:50:09 AM Jettro Coenradie wrote: --------------- >I allways used to create metadata with the following method > >ITableMetaData meta = new DatabaseTableMetaData("SCOTT",getConnection()); >ITable table = new DefaultTable(meta,columns); >DefaultDataSet defaultDS = new DefaultDataSet(table); > >However with version 2.0 I get the problem that the constructor is >protected. > >I want to create a defaultdataset with the metadata from a database. > >hope someone can tell me the alternative and why the constructor is made >protected. > >greetings Jettro Coenradie > An alternative is to get it from the DbUnit connection like this: IDataSet databaseDataSet = connection.createDataSet(); ITableMetaData metaData = databaseDataSet.getTableMetaData("SCOTT"); Why? I don't really remember why but this constructor is likely to change in the future. In fact it has already changed in the past but been reverted to its original signature except for public modifier. Getting the metadata from the connection should shield you from such changes. Tables' metadata are cached in the DbUnit connection, reusing the same connection thorough your suite is reputed more efficient. BTW, DefaultDataSet has new methods and you should found it easier to use. Manuel |