Problem loading DataSet from Flat XML

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem loading DataSet from Flat XML

Rafael Vanderlei
Hi,

I'm using DBUnit 2.4.8 and I'm having problem with the a dataset written in a flat xml similar to the following:

<dataset>
      <TableName columnOne="valueOne" columnTwo="ValueTwo" />
      <TableName columnThree="valueThree" columnFour="ValueFour" />
</dataset>

Then I have the following code in my TestCase's method annotated with @Before :

[code]
JdbcDatabaseTester jdbcDatabaseTester = new JdbcDatabaseTester();

DataFileLoader loader = new FlatXmlDataFileLoader();
IDataSet dataSet = loader.load("/path/to/dataset");
databaseTester.setDataSet(dataSet);

jdbcDatabaseTester.onSetup();
[/code]

When I run it, the result in the Database is such like running the following statements:
INSERT INTO TableName (columnOne, columnTwo) values ('valueOne', 'valueTwo')
INSERT INTO TableName (columnOne, columnTwo) values (null, null)

But I expected the result to be such like running the following statements:
INSERT INTO TableName (columnOne, columnTwo) values ('valueOne', 'valueTwo')
INSERT INTO TableName (columnThree, columnFour) values ('valueThree', 'valueFour')

It seems like DBUnit is caching the metadata for the table 'TableName'.

Is it a bug or is it some expected behavior from DBUnit?

Regards,
Rafael Vanderlei.

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Problem loading DataSet from Flat XML

Rafael Vanderlei
Ok, really sorry for previous email... I kept searching and found out about the feature "column sensing" and it is working now.

But I'm having another problem regarding a timestamp column. In the xml dataset I have dateColumn="2011-08-03 08:00:00" but DBUnit is inserting "2011-08-03 00:00:00" into the database. I also tried dateColumn="2011-08-03 08:00:00.000000000" but it also results the same.

Am I missing something again?

Regards,
Rafael Vanderlei.

On Thu, Aug 4, 2011 at 3:24 PM, Rafael Vanderlei <[hidden email]> wrote:
Hi,

I'm using DBUnit 2.4.8 and I'm having problem with the a dataset written in a flat xml similar to the following:

<dataset>
      <TableName columnOne="valueOne" columnTwo="ValueTwo" />
      <TableName columnThree="valueThree" columnFour="ValueFour" />
</dataset>

Then I have the following code in my TestCase's method annotated with @Before :

[code]
JdbcDatabaseTester jdbcDatabaseTester = new JdbcDatabaseTester();

DataFileLoader loader = new FlatXmlDataFileLoader();
IDataSet dataSet = loader.load("/path/to/dataset");
databaseTester.setDataSet(dataSet);

jdbcDatabaseTester.onSetup();
[/code]

When I run it, the result in the Database is such like running the following statements:
INSERT INTO TableName (columnOne, columnTwo) values ('valueOne', 'valueTwo')
INSERT INTO TableName (columnOne, columnTwo) values (null, null)

But I expected the result to be such like running the following statements:
INSERT INTO TableName (columnOne, columnTwo) values ('valueOne', 'valueTwo')
INSERT INTO TableName (columnThree, columnFour) values ('valueThree', 'valueFour')

It seems like DBUnit is caching the metadata for the table 'TableName'.

Is it a bug or is it some expected behavior from DBUnit?

Regards,
Rafael Vanderlei.


------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Problem loading DataSet from Flat XML

John Hurst-2
Hello,

Have you configured a DataTypeFactory appropriate for your database? With Oracle for example, I believe it's important to configure OracleDataTypeFactory in order to get correct handling of dates.

Regards

John Hurst
Wellington, New Zealand

On Fri, Aug 5, 2011 at 7:21 AM, Rafael Vanderlei <[hidden email]> wrote:
Ok, really sorry for previous email... I kept searching and found out about the feature "column sensing" and it is working now.

But I'm having another problem regarding a timestamp column. In the xml dataset I have dateColumn="2011-08-03 08:00:00" but DBUnit is inserting "2011-08-03 00:00:00" into the database. I also tried dateColumn="2011-08-03 08:00:00.000000000" but it also results the same.

Am I missing something again?

Regards,
Rafael Vanderlei.


On Thu, Aug 4, 2011 at 3:24 PM, Rafael Vanderlei <[hidden email]> wrote:
Hi,

I'm using DBUnit 2.4.8 and I'm having problem with the a dataset written in a flat xml similar to the following:

<dataset>
      <TableName columnOne="valueOne" columnTwo="ValueTwo" />
      <TableName columnThree="valueThree" columnFour="ValueFour" />
</dataset>

Then I have the following code in my TestCase's method annotated with @Before :

[code]
JdbcDatabaseTester jdbcDatabaseTester = new JdbcDatabaseTester();

DataFileLoader loader = new FlatXmlDataFileLoader();
IDataSet dataSet = loader.load("/path/to/dataset");
databaseTester.setDataSet(dataSet);

jdbcDatabaseTester.onSetup();
[/code]

When I run it, the result in the Database is such like running the following statements:
INSERT INTO TableName (columnOne, columnTwo) values ('valueOne', 'valueTwo')
INSERT INTO TableName (columnOne, columnTwo) values (null, null)

But I expected the result to be such like running the following statements:
INSERT INTO TableName (columnOne, columnTwo) values ('valueOne', 'valueTwo')
INSERT INTO TableName (columnThree, columnFour) values ('valueThree', 'valueFour')

It seems like DBUnit is caching the metadata for the table 'TableName'.

Is it a bug or is it some expected behavior from DBUnit?

Regards,
Rafael Vanderlei.


------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user




--
Life is interfering with my game

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Problem loading DataSet from Flat XML

Rafael Vanderlei
Hi, John.

Yes, I'm using Oracle and No, I didn't configure a DataTypeFactory because I have never heard of it before. I'll give it a try.

Thanks for response.

Regards,
Rafael Vanderlei.

On Mon, Aug 8, 2011 at 4:17 AM, John Hurst <[hidden email]> wrote:
Hello,

Have you configured a DataTypeFactory appropriate for your database? With Oracle for example, I believe it's important to configure OracleDataTypeFactory in order to get correct handling of dates.

Regards

John Hurst
Wellington, New Zealand

On Fri, Aug 5, 2011 at 7:21 AM, Rafael Vanderlei <[hidden email]> wrote:
Ok, really sorry for previous email... I kept searching and found out about the feature "column sensing" and it is working now.

But I'm having another problem regarding a timestamp column. In the xml dataset I have dateColumn="2011-08-03 08:00:00" but DBUnit is inserting "2011-08-03 00:00:00" into the database. I also tried dateColumn="2011-08-03 08:00:00.000000000" but it also results the same.

Am I missing something again?

Regards,
Rafael Vanderlei.


On Thu, Aug 4, 2011 at 3:24 PM, Rafael Vanderlei <[hidden email]> wrote:
Hi,

I'm using DBUnit 2.4.8 and I'm having problem with the a dataset written in a flat xml similar to the following:

<dataset>
      <TableName columnOne="valueOne" columnTwo="ValueTwo" />
      <TableName columnThree="valueThree" columnFour="ValueFour" />
</dataset>

Then I have the following code in my TestCase's method annotated with @Before :

[code]
JdbcDatabaseTester jdbcDatabaseTester = new JdbcDatabaseTester();

DataFileLoader loader = new FlatXmlDataFileLoader();
IDataSet dataSet = loader.load("/path/to/dataset");
databaseTester.setDataSet(dataSet);

jdbcDatabaseTester.onSetup();
[/code]

When I run it, the result in the Database is such like running the following statements:
INSERT INTO TableName (columnOne, columnTwo) values ('valueOne', 'valueTwo')
INSERT INTO TableName (columnOne, columnTwo) values (null, null)

But I expected the result to be such like running the following statements:
INSERT INTO TableName (columnOne, columnTwo) values ('valueOne', 'valueTwo')
INSERT INTO TableName (columnThree, columnFour) values ('valueThree', 'valueFour')

It seems like DBUnit is caching the metadata for the table 'TableName'.

Is it a bug or is it some expected behavior from DBUnit?

Regards,
Rafael Vanderlei.


------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user




--
Life is interfering with my game

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user



------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Problem loading DataSet from Flat XML

Rafael Vanderlei
Jonh, using OracleDataTypeFactory instead of DefaultDataTypeFactory solved the problem with timestamp.

Thanks for the tip.

Regards,
Rafael Vanderlei.

On Mon, Aug 8, 2011 at 9:17 AM, Rafael Vanderlei <[hidden email]> wrote:
Hi, John.

Yes, I'm using Oracle and No, I didn't configure a DataTypeFactory because I have never heard of it before. I'll give it a try.

Thanks for response.

Regards,
Rafael Vanderlei.


On Mon, Aug 8, 2011 at 4:17 AM, John Hurst <[hidden email]> wrote:
Hello,

Have you configured a DataTypeFactory appropriate for your database? With Oracle for example, I believe it's important to configure OracleDataTypeFactory in order to get correct handling of dates.

Regards

John Hurst
Wellington, New Zealand

On Fri, Aug 5, 2011 at 7:21 AM, Rafael Vanderlei <[hidden email]> wrote:
Ok, really sorry for previous email... I kept searching and found out about the feature "column sensing" and it is working now.

But I'm having another problem regarding a timestamp column. In the xml dataset I have dateColumn="2011-08-03 08:00:00" but DBUnit is inserting "2011-08-03 00:00:00" into the database. I also tried dateColumn="2011-08-03 08:00:00.000000000" but it also results the same.

Am I missing something again?

Regards,
Rafael Vanderlei.


On Thu, Aug 4, 2011 at 3:24 PM, Rafael Vanderlei <[hidden email]> wrote:
Hi,

I'm using DBUnit 2.4.8 and I'm having problem with the a dataset written in a flat xml similar to the following:

<dataset>
      <TableName columnOne="valueOne" columnTwo="ValueTwo" />
      <TableName columnThree="valueThree" columnFour="ValueFour" />
</dataset>

Then I have the following code in my TestCase's method annotated with @Before :

[code]
JdbcDatabaseTester jdbcDatabaseTester = new JdbcDatabaseTester();

DataFileLoader loader = new FlatXmlDataFileLoader();
IDataSet dataSet = loader.load("/path/to/dataset");
databaseTester.setDataSet(dataSet);

jdbcDatabaseTester.onSetup();
[/code]

When I run it, the result in the Database is such like running the following statements:
INSERT INTO TableName (columnOne, columnTwo) values ('valueOne', 'valueTwo')
INSERT INTO TableName (columnOne, columnTwo) values (null, null)

But I expected the result to be such like running the following statements:
INSERT INTO TableName (columnOne, columnTwo) values ('valueOne', 'valueTwo')
INSERT INTO TableName (columnThree, columnFour) values ('valueThree', 'valueFour')

It seems like DBUnit is caching the metadata for the table 'TableName'.

Is it a bug or is it some expected behavior from DBUnit?

Regards,
Rafael Vanderlei.


------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user




--
Life is interfering with my game

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user




------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user