Issue with Parent/Child constraint - Wrong insert order?

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

Issue with Parent/Child constraint - Wrong insert order?

saw303
Hi everybody

I am sure this question has been already asked in this mailing list but I could find it yet. Currently I am troubling with a parent/child relation and cannot understand dbUnits behaviour.

I am trying to insert the following dataset as FlatXmlDataSet using dbUnit 2.4.6.

<?xml version='1.0' encoding='UTF-8'?>
<dataset>
  <postbox ID="1" SHORT_NAME="COR" MESSAGE_KEY="group.pbox.cor"/>
  <group_postbox ID="1"/>

  <postbox ID="2" SHORT_NAME="CORINF" MESSAGE_KEY="group.pbox.corinf" PARENT_FK="1"/>
  <group_postbox ID="2"/>  
</dataset>

As it seems dbUnit does first all INSERT on table 'postbox' and fails (on postbox id 2) because of a foreign key constraint.

The dataset is created as follows:

return new FlatXmlDataSet(new FileReader(baseDataFilename), false, true, false);

Can anyone help me on this? How can I tell dbUnit 2.4.6 to first things first. Means first insert postbox 1 then group_post 1 after that postbox 2 and finally group_postbox 2?

Thank you in advance.
Silvio

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Parent/Child constraint - Wrong insert order?

Luiz Eduardo Guida Valmont-2
This is just a hunch, but here's my $0,02. Try grouping your group_postbox elements before the postbox ones. Your example shows a postbox short named "COR" as the very first element of the data set. Maybe that's the problem. Maybe.

Regards,
Luiz

2009/11/9 Silvio Wangler <[hidden email]>
Hi everybody

I am sure this question has been already asked in this mailing list but I could find it yet. Currently I am troubling with a parent/child relation and cannot understand dbUnits behaviour.

I am trying to insert the following dataset as FlatXmlDataSet using dbUnit 2.4.6.

<?xml version='1.0' encoding='UTF-8'?>
<dataset>
  <postbox ID="1" SHORT_NAME="COR" MESSAGE_KEY="group.pbox.cor"/>
  <group_postbox ID="1"/>

  <postbox ID="2" SHORT_NAME="CORINF" MESSAGE_KEY="group.pbox.corinf" PARENT_FK="1"/>
  <group_postbox ID="2"/>  
</dataset>

As it seems dbUnit does first all INSERT on table 'postbox' and fails (on postbox id 2) because of a foreign key constraint.

The dataset is created as follows:

return new FlatXmlDataSet(new FileReader(baseDataFilename), false, true, false);

Can anyone help me on this? How can I tell dbUnit 2.4.6 to first things first. Means first insert postbox 1 then group_post 1 after that postbox 2 and finally group_postbox 2?

Thank you in advance.
Silvio

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Parent/Child constraint - Wrong insert order?

saw303
Hi Luiz,

Thank you for your quick answer.

Well due to the DDL I think I cannot do that. group_postbox(id) refers
to postbox(id). Or isn't the order of my xml dataset as dbUnit
executes the inserts?

2009/11/9 Luiz Eduardo Guida Valmont <[hidden email]>:

> This is just a hunch, but here's my $0,02. Try grouping your group_postbox
> elements before the postbox ones. Your example shows a postbox short named
> "COR" as the very first element of the data set. Maybe that's the problem.
> Maybe.
>
> Regards,
> Luiz
>
> 2009/11/9 Silvio Wangler <[hidden email]>
>>
>> Hi everybody
>>
>> I am sure this question has been already asked in this mailing list but I
>> could find it yet. Currently I am troubling with a parent/child relation and
>> cannot understand dbUnits behaviour.
>>
>> I am trying to insert the following dataset as FlatXmlDataSet using dbUnit
>> 2.4.6.
>>
>> <?xml version='1.0' encoding='UTF-8'?>
>> <dataset>
>>   <postbox ID="1" SHORT_NAME="COR" MESSAGE_KEY="group.pbox.cor"/>
>>   <group_postbox ID="1"/>
>>
>>   <postbox ID="2" SHORT_NAME="CORINF" MESSAGE_KEY="group.pbox.corinf"
>> PARENT_FK="1"/>
>>   <group_postbox ID="2"/>
>> </dataset>
>>
>> As it seems dbUnit does first all INSERT on table 'postbox' and fails (on
>> postbox id 2) because of a foreign key constraint.
>> The dataset is created as follows:
>> return new FlatXmlDataSet(new FileReader(baseDataFilename), false, true,
>> false);
>>
>> Can anyone help me on this? How can I tell dbUnit 2.4.6 to first things
>> first. Means first insert postbox 1 then group_post 1 after that postbox 2
>> and finally group_postbox 2?
>> Thank you in advance.
>> Silvio
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>> 30-Day
>> trial. Simplify your report design, integration and deployment - and focus
>> on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> dbunit-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>>
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> dbunit-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Parent/Child constraint - Wrong insert order?

Luiz Eduardo Guida Valmont-2
Hi Silvio,

From what I could learn of your dataset, you've got two tables: postbox and group_postbox; I guess postbox.parent_fk is a foreign key that refers to group_postbox.id (mainly because group_postbox seems to have no other attributes). That said, I thought that you might try the following dataset:

<?xml version='1.0' encoding='UTF-8'?>
<dataset>
  <!-- first, all group_postboxes -->
  <group_postbox ID="1"/>
  <group_postbox ID="2"/>

  <!-- then the postboxes themselves -->
  <postbox ID="1" SHORT_NAME="COR" MESSAGE_KEY="group.pbox.cor"/>
  <postbox ID="2" SHORT_NAME="CORINF" MESSAGE_KEY="group.pbox.corinf" PARENT_FK="1"/>
</dataset>

Regards,
Luiz

2009/11/9 Silvio Wangler <[hidden email]>
Hi Luiz,

Thank you for your quick answer.

Well due to the DDL I think I cannot do that. group_postbox(id) refers
to postbox(id). Or isn't the order of my xml dataset as dbUnit
executes the inserts?

2009/11/9 Luiz Eduardo Guida Valmont <[hidden email]>:
> This is just a hunch, but here's my $0,02. Try grouping your group_postbox
> elements before the postbox ones. Your example shows a postbox short named
> "COR" as the very first element of the data set. Maybe that's the problem.
> Maybe.
>
> Regards,
> Luiz
>
> 2009/11/9 Silvio Wangler <[hidden email]>
>>
>> Hi everybody
>>
>> I am sure this question has been already asked in this mailing list but I
>> could find it yet. Currently I am troubling with a parent/child relation and
>> cannot understand dbUnits behaviour.
>>
>> I am trying to insert the following dataset as FlatXmlDataSet using dbUnit
>> 2.4.6.
>>
>> <?xml version='1.0' encoding='UTF-8'?>
>> <dataset>
>>   <postbox ID="1" SHORT_NAME="COR" MESSAGE_KEY="group.pbox.cor"/>
>>   <group_postbox ID="1"/>
>>
>>   <postbox ID="2" SHORT_NAME="CORINF" MESSAGE_KEY="group.pbox.corinf"
>> PARENT_FK="1"/>
>>   <group_postbox ID="2"/>
>> </dataset>
>>
>> As it seems dbUnit does first all INSERT on table 'postbox' and fails (on
>> postbox id 2) because of a foreign key constraint.
>> The dataset is created as follows:
>> return new FlatXmlDataSet(new FileReader(baseDataFilename), false, true,
>> false);
>>
>> Can anyone help me on this? How can I tell dbUnit 2.4.6 to first things
>> first. Means first insert postbox 1 then group_post 1 after that postbox 2
>> and finally group_postbox 2?
>> Thank you in advance.
>> Silvio
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>> 30-Day
>> trial. Simplify your report design, integration and deployment - and focus
>> on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> dbunit-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>>
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> dbunit-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Parent/Child constraint - Wrong insert order?

saw303
Hi Luiz

I am sorry. Let me describe the two tables to you.

postbox
------------
id // PK
parent_fk // optional FK to a parent postbox; refers to postbox(id).
If NULL it's a root postbox w/o parent

group_postbox
---------------------
id // PK refers to postbox(id)
(...) // and some additional values

In the meantime I have downgraded my project to dbUnit 2.1. In 2.1
everything works as expected. If I upgrade to 2.2 it starts to fail.
If I change the dataset as you have suggested I get a constraint
violation (group_postbox --> postbox).

Any clue what else can be done?

Thank you und best regards
Silvio

2009/11/9 Luiz Eduardo Guida Valmont <[hidden email]>:

> Hi Silvio,
>
> From what I could learn of your dataset, you've got two tables: postbox and
> group_postbox; I guess postbox.parent_fk is a foreign key that refers to
> group_postbox.id (mainly because group_postbox seems to have no other
> attributes). That said, I thought that you might try the following dataset:
>
>> <?xml version='1.0' encoding='UTF-8'?>
>> <dataset>
>>   <!-- first, all group_postboxes -->
>>   <group_postbox ID="1"/>
>>   <group_postbox ID="2"/>
>>
>>   <!-- then the postboxes themselves -->
>>   <postbox ID="1" SHORT_NAME="COR" MESSAGE_KEY="group.pbox.cor"/>
>>   <postbox ID="2" SHORT_NAME="CORINF" MESSAGE_KEY="group.pbox.corinf"
>> PARENT_FK="1"/>
>> </dataset>
>
> Regards,
> Luiz
> 2009/11/9 Silvio Wangler <[hidden email]>
>>
>> Hi Luiz,
>>
>> Thank you for your quick answer.
>>
>> Well due to the DDL I think I cannot do that. group_postbox(id) refers
>> to postbox(id). Or isn't the order of my xml dataset as dbUnit
>> executes the inserts?
>>
>> 2009/11/9 Luiz Eduardo Guida Valmont <[hidden email]>:
>> > This is just a hunch, but here's my $0,02. Try grouping your
>> > group_postbox
>> > elements before the postbox ones. Your example shows a postbox short
>> > named
>> > "COR" as the very first element of the data set. Maybe that's the
>> > problem.
>> > Maybe.
>> >
>> > Regards,
>> > Luiz
>> >
>> > 2009/11/9 Silvio Wangler <[hidden email]>
>> >>
>> >> Hi everybody
>> >>
>> >> I am sure this question has been already asked in this mailing list but
>> >> I
>> >> could find it yet. Currently I am troubling with a parent/child
>> >> relation and
>> >> cannot understand dbUnits behaviour.
>> >>
>> >> I am trying to insert the following dataset as FlatXmlDataSet using
>> >> dbUnit
>> >> 2.4.6.
>> >>
>> >> <?xml version='1.0' encoding='UTF-8'?>
>> >> <dataset>
>> >>   <postbox ID="1" SHORT_NAME="COR" MESSAGE_KEY="group.pbox.cor"/>
>> >>   <group_postbox ID="1"/>
>> >>
>> >>   <postbox ID="2" SHORT_NAME="CORINF" MESSAGE_KEY="group.pbox.corinf"
>> >> PARENT_FK="1"/>
>> >>   <group_postbox ID="2"/>
>> >> </dataset>
>> >>
>> >> As it seems dbUnit does first all INSERT on table 'postbox' and fails
>> >> (on
>> >> postbox id 2) because of a foreign key constraint.
>> >> The dataset is created as follows:
>> >> return new FlatXmlDataSet(new FileReader(baseDataFilename), false,
>> >> true,
>> >> false);
>> >>
>> >> Can anyone help me on this? How can I tell dbUnit 2.4.6 to first things
>> >> first. Means first insert postbox 1 then group_post 1 after that
>> >> postbox 2
>> >> and finally group_postbox 2?
>> >> Thank you in advance.
>> >> Silvio
>> >>
>> >>
>> >> ------------------------------------------------------------------------------
>> >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>> >> 30-Day
>> >> trial. Simplify your report design, integration and deployment - and
>> >> focus
>> >> on
>> >> what you do best, core application coding. Discover what's new with
>> >> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> >> _______________________________________________
>> >> dbunit-user mailing list
>> >> [hidden email]
>> >> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>> >>
>> >
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>> > 30-Day
>> > trial. Simplify your report design, integration and deployment - and
>> > focus
>> > on
>> > what you do best, core application coding. Discover what's new with
>> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> > _______________________________________________
>> > dbunit-user mailing list
>> > [hidden email]
>> > https://lists.sourceforge.net/lists/listinfo/dbunit-user
>> >
>> >
>>
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>> 30-Day
>> trial. Simplify your report design, integration and deployment - and focus
>> on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> dbunit-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> dbunit-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Parent/Child constraint - Wrong insert order?

Roberto Lo Giacco-4
DbUnit statements are not executed in the same order they are listed
in your dataset but they are grouped on a table basis.

I don't remember why we changed this behavior and I'm not completely
sure it happened on 2.2 release... may be this is related to the
column sensing feature....

   Roberto Lo Giacco



On Mon, Nov 9, 2009 at 16:37, Silvio Wangler <[hidden email]> wrote:

> Hi Luiz
>
> I am sorry. Let me describe the two tables to you.
>
> postbox
> ------------
> id // PK
> parent_fk // optional FK to a parent postbox; refers to postbox(id).
> If NULL it's a root postbox w/o parent
>
> group_postbox
> ---------------------
> id // PK refers to postbox(id)
> (...) // and some additional values
>
> In the meantime I have downgraded my project to dbUnit 2.1. In 2.1
> everything works as expected. If I upgrade to 2.2 it starts to fail.
> If I change the dataset as you have suggested I get a constraint
> violation (group_postbox --> postbox).
>
> Any clue what else can be done?
>
> Thank you und best regards
> Silvio
>
> 2009/11/9 Luiz Eduardo Guida Valmont <[hidden email]>:
>> Hi Silvio,
>>
>> From what I could learn of your dataset, you've got two tables: postbox and
>> group_postbox; I guess postbox.parent_fk is a foreign key that refers to
>> group_postbox.id (mainly because group_postbox seems to have no other
>> attributes). That said, I thought that you might try the following dataset:
>>
>>> <?xml version='1.0' encoding='UTF-8'?>
>>> <dataset>
>>>   <!-- first, all group_postboxes -->
>>>   <group_postbox ID="1"/>
>>>   <group_postbox ID="2"/>
>>>
>>>   <!-- then the postboxes themselves -->
>>>   <postbox ID="1" SHORT_NAME="COR" MESSAGE_KEY="group.pbox.cor"/>
>>>   <postbox ID="2" SHORT_NAME="CORINF" MESSAGE_KEY="group.pbox.corinf"
>>> PARENT_FK="1"/>
>>> </dataset>
>>
>> Regards,
>> Luiz
>> 2009/11/9 Silvio Wangler <[hidden email]>
>>>
>>> Hi Luiz,
>>>
>>> Thank you for your quick answer.
>>>
>>> Well due to the DDL I think I cannot do that. group_postbox(id) refers
>>> to postbox(id). Or isn't the order of my xml dataset as dbUnit
>>> executes the inserts?
>>>
>>> 2009/11/9 Luiz Eduardo Guida Valmont <[hidden email]>:
>>> > This is just a hunch, but here's my $0,02. Try grouping your
>>> > group_postbox
>>> > elements before the postbox ones. Your example shows a postbox short
>>> > named
>>> > "COR" as the very first element of the data set. Maybe that's the
>>> > problem.
>>> > Maybe.
>>> >
>>> > Regards,
>>> > Luiz
>>> >
>>> > 2009/11/9 Silvio Wangler <[hidden email]>
>>> >>
>>> >> Hi everybody
>>> >>
>>> >> I am sure this question has been already asked in this mailing list but
>>> >> I
>>> >> could find it yet. Currently I am troubling with a parent/child
>>> >> relation and
>>> >> cannot understand dbUnits behaviour.
>>> >>
>>> >> I am trying to insert the following dataset as FlatXmlDataSet using
>>> >> dbUnit
>>> >> 2.4.6.
>>> >>
>>> >> <?xml version='1.0' encoding='UTF-8'?>
>>> >> <dataset>
>>> >>   <postbox ID="1" SHORT_NAME="COR" MESSAGE_KEY="group.pbox.cor"/>
>>> >>   <group_postbox ID="1"/>
>>> >>
>>> >>   <postbox ID="2" SHORT_NAME="CORINF" MESSAGE_KEY="group.pbox.corinf"
>>> >> PARENT_FK="1"/>
>>> >>   <group_postbox ID="2"/>
>>> >> </dataset>
>>> >>
>>> >> As it seems dbUnit does first all INSERT on table 'postbox' and fails
>>> >> (on
>>> >> postbox id 2) because of a foreign key constraint.
>>> >> The dataset is created as follows:
>>> >> return new FlatXmlDataSet(new FileReader(baseDataFilename), false,
>>> >> true,
>>> >> false);
>>> >>
>>> >> Can anyone help me on this? How can I tell dbUnit 2.4.6 to first things
>>> >> first. Means first insert postbox 1 then group_post 1 after that
>>> >> postbox 2
>>> >> and finally group_postbox 2?
>>> >> Thank you in advance.
>>> >> Silvio
>>> >>
>>> >>
>>> >> ------------------------------------------------------------------------------
>>> >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>>> >> 30-Day
>>> >> trial. Simplify your report design, integration and deployment - and
>>> >> focus
>>> >> on
>>> >> what you do best, core application coding. Discover what's new with
>>> >> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>> >> _______________________________________________
>>> >> dbunit-user mailing list
>>> >> [hidden email]
>>> >> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>>> >>
>>> >
>>> >
>>> >
>>> > ------------------------------------------------------------------------------
>>> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>>> > 30-Day
>>> > trial. Simplify your report design, integration and deployment - and
>>> > focus
>>> > on
>>> > what you do best, core application coding. Discover what's new with
>>> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>> > _______________________________________________
>>> > dbunit-user mailing list
>>> > [hidden email]
>>> > https://lists.sourceforge.net/lists/listinfo/dbunit-user
>>> >
>>> >
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>>> 30-Day
>>> trial. Simplify your report design, integration and deployment - and focus
>>> on
>>> what you do best, core application coding. Discover what's new with
>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>> _______________________________________________
>>> dbunit-user mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>>
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
>> trial. Simplify your report design, integration and deployment - and focus
>> on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> dbunit-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>>
>>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> dbunit-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Parent/Child constraint - Wrong insert order?

saw303
Hi Roberto 

Thank you very much for that answer. It proofs my analysis of today since AbstractDataSet holds all table names in a OrderedTableNameMap und the CachedDataSet returns a list of the map values (table names).

Is there any point within dbUnit where I could hook in to change this behaviour? Should not there be a way to have XML datasets in the same way as SQL scripts?

Best regards
Silvio


2009/11/9 Roberto Lo Giacco <[hidden email]>
DbUnit statements are not executed in the same order they are listed
in your dataset but they are grouped on a table basis.

I don't remember why we changed this behavior and I'm not completely
sure it happened on 2.2 release... may be this is related to the
column sensing feature....

  Roberto Lo Giacco



On Mon, Nov 9, 2009 at 16:37, Silvio Wangler <[hidden email]> wrote:
> Hi Luiz
>
> I am sorry. Let me describe the two tables to you.
>
> postbox
> ------------
> id // PK
> parent_fk // optional FK to a parent postbox; refers to postbox(id).
> If NULL it's a root postbox w/o parent
>
> group_postbox
> ---------------------
> id // PK refers to postbox(id)
> (...) // and some additional values
>
> In the meantime I have downgraded my project to dbUnit 2.1. In 2.1
> everything works as expected. If I upgrade to 2.2 it starts to fail.
> If I change the dataset as you have suggested I get a constraint
> violation (group_postbox --> postbox).
>
> Any clue what else can be done?
>
> Thank you und best regards
> Silvio
>
> 2009/11/9 Luiz Eduardo Guida Valmont <[hidden email]>:
>> Hi Silvio,
>>
>> From what I could learn of your dataset, you've got two tables: postbox and
>> group_postbox; I guess postbox.parent_fk is a foreign key that refers to
>> group_postbox.id (mainly because group_postbox seems to have no other
>> attributes). That said, I thought that you might try the following dataset:
>>
>>> <?xml version='1.0' encoding='UTF-8'?>
>>> <dataset>
>>>   <!-- first, all group_postboxes -->
>>>   <group_postbox ID="1"/>
>>>   <group_postbox ID="2"/>
>>>
>>>   <!-- then the postboxes themselves -->
>>>   <postbox ID="1" SHORT_NAME="COR" MESSAGE_KEY="group.pbox.cor"/>
>>>   <postbox ID="2" SHORT_NAME="CORINF" MESSAGE_KEY="group.pbox.corinf"
>>> PARENT_FK="1"/>
>>> </dataset>
>>
>> Regards,
>> Luiz
>> 2009/11/9 Silvio Wangler <[hidden email]>
>>>
>>> Hi Luiz,
>>>
>>> Thank you for your quick answer.
>>>
>>> Well due to the DDL I think I cannot do that. group_postbox(id) refers
>>> to postbox(id). Or isn't the order of my xml dataset as dbUnit
>>> executes the inserts?
>>>
>>> 2009/11/9 Luiz Eduardo Guida Valmont <[hidden email]>:
>>> > This is just a hunch, but here's my $0,02. Try grouping your
>>> > group_postbox
>>> > elements before the postbox ones. Your example shows a postbox short
>>> > named
>>> > "COR" as the very first element of the data set. Maybe that's the
>>> > problem.
>>> > Maybe.
>>> >
>>> > Regards,
>>> > Luiz
>>> >
>>> > 2009/11/9 Silvio Wangler <[hidden email]>
>>> >>
>>> >> Hi everybody
>>> >>
>>> >> I am sure this question has been already asked in this mailing list but
>>> >> I
>>> >> could find it yet. Currently I am troubling with a parent/child
>>> >> relation and
>>> >> cannot understand dbUnits behaviour.
>>> >>
>>> >> I am trying to insert the following dataset as FlatXmlDataSet using
>>> >> dbUnit
>>> >> 2.4.6.
>>> >>
>>> >> <?xml version='1.0' encoding='UTF-8'?>
>>> >> <dataset>
>>> >>   <postbox ID="1" SHORT_NAME="COR" MESSAGE_KEY="group.pbox.cor"/>
>>> >>   <group_postbox ID="1"/>
>>> >>
>>> >>   <postbox ID="2" SHORT_NAME="CORINF" MESSAGE_KEY="group.pbox.corinf"
>>> >> PARENT_FK="1"/>
>>> >>   <group_postbox ID="2"/>
>>> >> </dataset>
>>> >>
>>> >> As it seems dbUnit does first all INSERT on table 'postbox' and fails
>>> >> (on
>>> >> postbox id 2) because of a foreign key constraint.
>>> >> The dataset is created as follows:
>>> >> return new FlatXmlDataSet(new FileReader(baseDataFilename), false,
>>> >> true,
>>> >> false);
>>> >>
>>> >> Can anyone help me on this? How can I tell dbUnit 2.4.6 to first things
>>> >> first. Means first insert postbox 1 then group_post 1 after that
>>> >> postbox 2
>>> >> and finally group_postbox 2?
>>> >> Thank you in advance.
>>> >> Silvio
>>> >>
>>> >>
>>> >> ------------------------------------------------------------------------------
>>> >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>>> >> 30-Day
>>> >> trial. Simplify your report design, integration and deployment - and
>>> >> focus
>>> >> on
>>> >> what you do best, core application coding. Discover what's new with
>>> >> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>> >> _______________________________________________
>>> >> dbunit-user mailing list
>>> >> [hidden email]
>>> >> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>>> >>
>>> >
>>> >
>>> >
>>> > ------------------------------------------------------------------------------
>>> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>>> > 30-Day
>>> > trial. Simplify your report design, integration and deployment - and
>>> > focus
>>> > on
>>> > what you do best, core application coding. Discover what's new with
>>> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>> > _______________________________________________
>>> > dbunit-user mailing list
>>> > [hidden email]
>>> > https://lists.sourceforge.net/lists/listinfo/dbunit-user
>>> >
>>> >
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>>> 30-Day
>>> trial. Simplify your report design, integration and deployment - and focus
>>> on
>>> what you do best, core application coding. Discover what's new with
>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>> _______________________________________________
>>> dbunit-user mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>>
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
>> trial. Simplify your report design, integration and deployment - and focus
>> on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> dbunit-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>>
>>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> dbunit-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Parent/Child constraint - Wrong insert order?

Roberto Lo Giacco-4
I would prefer if it were possible for you to talk about this with the
developer who applied that change who, if I remember correctly, should
be Sebastien.

In any case it would be perfect in my opinion if we could have both
features: column sensing AND statements order.


   Roberto Lo Giacco



On Mon, Nov 9, 2009 at 19:19, Silvio Wangler <[hidden email]> wrote:

> Hi Roberto
> Thank you very much for that answer. It proofs my analysis of today
> since AbstractDataSet holds all table names in a OrderedTableNameMap und
> the CachedDataSet returns a list of the map values (table names).
> Is there any point within dbUnit where I could hook in to change this
> behaviour? Should not there be a way to have XML datasets in the same way as
> SQL scripts?
> Best regards
> Silvio
>
> 2009/11/9 Roberto Lo Giacco <[hidden email]>
>>
>> DbUnit statements are not executed in the same order they are listed
>> in your dataset but they are grouped on a table basis.
>>
>> I don't remember why we changed this behavior and I'm not completely
>> sure it happened on 2.2 release... may be this is related to the
>> column sensing feature....
>>
>>   Roberto Lo Giacco
>>
>>
>>
>> On Mon, Nov 9, 2009 at 16:37, Silvio Wangler <[hidden email]>
>> wrote:
>> > Hi Luiz
>> >
>> > I am sorry. Let me describe the two tables to you.
>> >
>> > postbox
>> > ------------
>> > id // PK
>> > parent_fk // optional FK to a parent postbox; refers to postbox(id).
>> > If NULL it's a root postbox w/o parent
>> >
>> > group_postbox
>> > ---------------------
>> > id // PK refers to postbox(id)
>> > (...) // and some additional values
>> >
>> > In the meantime I have downgraded my project to dbUnit 2.1. In 2.1
>> > everything works as expected. If I upgrade to 2.2 it starts to fail.
>> > If I change the dataset as you have suggested I get a constraint
>> > violation (group_postbox --> postbox).
>> >
>> > Any clue what else can be done?
>> >
>> > Thank you und best regards
>> > Silvio
>> >
>> > 2009/11/9 Luiz Eduardo Guida Valmont <[hidden email]>:
>> >> Hi Silvio,
>> >>
>> >> From what I could learn of your dataset, you've got two tables: postbox
>> >> and
>> >> group_postbox; I guess postbox.parent_fk is a foreign key that refers
>> >> to
>> >> group_postbox.id (mainly because group_postbox seems to have no other
>> >> attributes). That said, I thought that you might try the following
>> >> dataset:
>> >>
>> >>> <?xml version='1.0' encoding='UTF-8'?>
>> >>> <dataset>
>> >>>   <!-- first, all group_postboxes -->
>> >>>   <group_postbox ID="1"/>
>> >>>   <group_postbox ID="2"/>
>> >>>
>> >>>   <!-- then the postboxes themselves -->
>> >>>   <postbox ID="1" SHORT_NAME="COR" MESSAGE_KEY="group.pbox.cor"/>
>> >>>   <postbox ID="2" SHORT_NAME="CORINF" MESSAGE_KEY="group.pbox.corinf"
>> >>> PARENT_FK="1"/>
>> >>> </dataset>
>> >>
>> >> Regards,
>> >> Luiz
>> >> 2009/11/9 Silvio Wangler <[hidden email]>
>> >>>
>> >>> Hi Luiz,
>> >>>
>> >>> Thank you for your quick answer.
>> >>>
>> >>> Well due to the DDL I think I cannot do that. group_postbox(id) refers
>> >>> to postbox(id). Or isn't the order of my xml dataset as dbUnit
>> >>> executes the inserts?
>> >>>
>> >>> 2009/11/9 Luiz Eduardo Guida Valmont <[hidden email]>:
>> >>> > This is just a hunch, but here's my $0,02. Try grouping your
>> >>> > group_postbox
>> >>> > elements before the postbox ones. Your example shows a postbox short
>> >>> > named
>> >>> > "COR" as the very first element of the data set. Maybe that's the
>> >>> > problem.
>> >>> > Maybe.
>> >>> >
>> >>> > Regards,
>> >>> > Luiz
>> >>> >
>> >>> > 2009/11/9 Silvio Wangler <[hidden email]>
>> >>> >>
>> >>> >> Hi everybody
>> >>> >>
>> >>> >> I am sure this question has been already asked in this mailing list
>> >>> >> but
>> >>> >> I
>> >>> >> could find it yet. Currently I am troubling with a parent/child
>> >>> >> relation and
>> >>> >> cannot understand dbUnits behaviour.
>> >>> >>
>> >>> >> I am trying to insert the following dataset as FlatXmlDataSet using
>> >>> >> dbUnit
>> >>> >> 2.4.6.
>> >>> >>
>> >>> >> <?xml version='1.0' encoding='UTF-8'?>
>> >>> >> <dataset>
>> >>> >>   <postbox ID="1" SHORT_NAME="COR" MESSAGE_KEY="group.pbox.cor"/>
>> >>> >>   <group_postbox ID="1"/>
>> >>> >>
>> >>> >>   <postbox ID="2" SHORT_NAME="CORINF"
>> >>> >> MESSAGE_KEY="group.pbox.corinf"
>> >>> >> PARENT_FK="1"/>
>> >>> >>   <group_postbox ID="2"/>
>> >>> >> </dataset>
>> >>> >>
>> >>> >> As it seems dbUnit does first all INSERT on table 'postbox' and
>> >>> >> fails
>> >>> >> (on
>> >>> >> postbox id 2) because of a foreign key constraint.
>> >>> >> The dataset is created as follows:
>> >>> >> return new FlatXmlDataSet(new FileReader(baseDataFilename), false,
>> >>> >> true,
>> >>> >> false);
>> >>> >>
>> >>> >> Can anyone help me on this? How can I tell dbUnit 2.4.6 to first
>> >>> >> things
>> >>> >> first. Means first insert postbox 1 then group_post 1 after that
>> >>> >> postbox 2
>> >>> >> and finally group_postbox 2?
>> >>> >> Thank you in advance.
>> >>> >> Silvio
>> >>> >>
>> >>> >>
>> >>> >>
>> >>> >> ------------------------------------------------------------------------------
>> >>> >> Let Crystal Reports handle the reporting - Free Crystal Reports
>> >>> >> 2008
>> >>> >> 30-Day
>> >>> >> trial. Simplify your report design, integration and deployment -
>> >>> >> and
>> >>> >> focus
>> >>> >> on
>> >>> >> what you do best, core application coding. Discover what's new with
>> >>> >> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> >>> >> _______________________________________________
>> >>> >> dbunit-user mailing list
>> >>> >> [hidden email]
>> >>> >> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>> >>> >>
>> >>> >
>> >>> >
>> >>> >
>> >>> >
>> >>> > ------------------------------------------------------------------------------
>> >>> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>> >>> > 30-Day
>> >>> > trial. Simplify your report design, integration and deployment - and
>> >>> > focus
>> >>> > on
>> >>> > what you do best, core application coding. Discover what's new with
>> >>> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> >>> > _______________________________________________
>> >>> > dbunit-user mailing list
>> >>> > [hidden email]
>> >>> > https://lists.sourceforge.net/lists/listinfo/dbunit-user
>> >>> >
>> >>> >
>> >>>
>> >>>
>> >>>
>> >>> ------------------------------------------------------------------------------
>> >>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>> >>> 30-Day
>> >>> trial. Simplify your report design, integration and deployment - and
>> >>> focus
>> >>> on
>> >>> what you do best, core application coding. Discover what's new with
>> >>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> >>> _______________________________________________
>> >>> dbunit-user mailing list
>> >>> [hidden email]
>> >>> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>> >>
>> >>
>> >>
>> >> ------------------------------------------------------------------------------
>> >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>> >> 30-Day
>> >> trial. Simplify your report design, integration and deployment - and
>> >> focus
>> >> on
>> >> what you do best, core application coding. Discover what's new with
>> >> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> >> _______________________________________________
>> >> dbunit-user mailing list
>> >> [hidden email]
>> >> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>> >>
>> >>
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>> > 30-Day
>> > trial. Simplify your report design, integration and deployment - and
>> > focus on
>> > what you do best, core application coding. Discover what's new with
>> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> > _______________________________________________
>> > dbunit-user mailing list
>> > [hidden email]
>> > https://lists.sourceforge.net/lists/listinfo/dbunit-user
>> >
>>
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>> 30-Day
>> trial. Simplify your report design, integration and deployment - and focus
>> on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> dbunit-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> dbunit-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Parent/Child constraint - Wrong insert order?

Matthias Gommeringer
In reply to this post by saw303
Hi guys,

I agree: it would be nice to have both columnSensing and kind of literal/verbose/ordered processing of the inserts, although I guess that it's not due to the column sensing since the parsed XML is grouped in ITable objects anyway (if I remember correctly that was also the case before the columnSensing feature was introduced). I think your initial approach to assume that the XML order is also used as the DB insert order is intuitive and natural and it actually should work this way. Could you submit a feature request for this?

rgds,
matthias

> -----Ursprüngliche Nachricht-----
> Von: "Roberto Lo Giacco" <[hidden email]>
> Gesendet: 10.11.09 15:20:28
> An: [hidden email]
> Betreff: Re: [dbunit-user] Issue with Parent/Child constraint - Wrong insert order?


> I would prefer if it were possible for you to talk about this with the
> developer who applied that change who, if I remember correctly, should
> be Sebastien.
>
> In any case it would be perfect in my opinion if we could have both
> features: column sensing AND statements order.
>
>
>    Roberto Lo Giacco
>
>
>
> On Mon, Nov 9, 2009 at 19:19, Silvio Wangler <[hidden email]> wrote:
> > Hi Roberto
> > Thank you very much for that answer. It proofs my analysis of today
> > since AbstractDataSet holds all table names in a OrderedTableNameMap und
> > the CachedDataSet returns a list of the map values (table names).
> > Is there any point within dbUnit where I could hook in to change this
> > behaviour? Should not there be a way to have XML datasets in the same way as
> > SQL scripts?
> > Best regards
> > Silvio
> >
> > 2009/11/9 Roberto Lo Giacco <[hidden email]>
> >>
> >> DbUnit statements are not executed in the same order they are listed
> >> in your dataset but they are grouped on a table basis.
> >>
> >> I don't remember why we changed this behavior and I'm not completely
> >> sure it happened on 2.2 release... may be this is related to the
> >> column sensing feature....
> >>
> >>   Roberto Lo Giacco
> >>
> >>
> >>
> >> On Mon, Nov 9, 2009 at 16:37, Silvio Wangler <[hidden email]>
> >> wrote:
> >> > Hi Luiz
> >> >
> >> > I am sorry. Let me describe the two tables to you.
> >> >
> >> > postbox
> >> > ------------
> >> > id // PK
> >> > parent_fk // optional FK to a parent postbox; refers to postbox(id).
> >> > If NULL it's a root postbox w/o parent
> >> >
> >> > group_postbox
> >> > ---------------------
> >> > id // PK refers to postbox(id)
> >> > (...) // and some additional values
> >> >
> >> > In the meantime I have downgraded my project to dbUnit 2.1. In 2.1
> >> > everything works as expected. If I upgrade to 2.2 it starts to fail.
> >> > If I change the dataset as you have suggested I get a constraint
> >> > violation (group_postbox --> postbox).
> >> >
> >> > Any clue what else can be done?
> >> >
> >> > Thank you und best regards
> >> > Silvio
> >> >
> >> > 2009/11/9 Luiz Eduardo Guida Valmont <[hidden email]>:
> >> >> Hi Silvio,
> >> >>
> >> >> From what I could learn of your dataset, you've got two tables: postbox
> >> >> and
> >> >> group_postbox; I guess postbox.parent_fk is a foreign key that refers
> >> >> to
> >> >> group_postbox.id (mainly because group_postbox seems to have no other
> >> >> attributes). That said, I thought that you might try the following
> >> >> dataset:
> >> >>
> >> >>> <?xml version='1.0' encoding='UTF-8'?>
> >> >>> <dataset>
> >> >>>   <!-- first, all group_postboxes -->
> >> >>>   <group_postbox ID="1"/>
> >> >>>   <group_postbox ID="2"/>
> >> >>>
> >> >>>   <!-- then the postboxes themselves -->
> >> >>>   <postbox ID="1" SHORT_NAME="COR" MESSAGE_KEY="group.pbox.cor"/>
> >> >>>   <postbox ID="2" SHORT_NAME="CORINF" MESSAGE_KEY="group.pbox.corinf"
> >> >>> PARENT_FK="1"/>
> >> >>> </dataset>
> >> >>
> >> >> Regards,
> >> >> Luiz
> >> >> 2009/11/9 Silvio Wangler <[hidden email]>
> >> >>>
> >> >>> Hi Luiz,
> >> >>>
> >> >>> Thank you for your quick answer.
> >> >>>
> >> >>> Well due to the DDL I think I cannot do that. group_postbox(id) refers
> >> >>> to postbox(id). Or isn't the order of my xml dataset as dbUnit
> >> >>> executes the inserts?
> >> >>>
> >> >>> 2009/11/9 Luiz Eduardo Guida Valmont <[hidden email]>:
> >> >>> > This is just a hunch, but here's my $0,02. Try grouping your
> >> >>> > group_postbox
> >> >>> > elements before the postbox ones. Your example shows a postbox short
> >> >>> > named
> >> >>> > "COR" as the very first element of the data set. Maybe that's the
> >> >>> > problem.
> >> >>> > Maybe.
> >> >>> >
> >> >>> > Regards,
> >> >>> > Luiz
> >> >>> >
> >> >>> > 2009/11/9 Silvio Wangler <[hidden email]>
> >> >>> >>
> >> >>> >> Hi everybody
> >> >>> >>
> >> >>> >> I am sure this question has been already asked in this mailing list
> >> >>> >> but
> >> >>> >> I
> >> >>> >> could find it yet. Currently I am troubling with a parent/child
> >> >>> >> relation and
> >> >>> >> cannot understand dbUnits behaviour.
> >> >>> >>
> >> >>> >> I am trying to insert the following dataset as FlatXmlDataSet using
> >> >>> >> dbUnit
> >> >>> >> 2.4.6.
> >> >>> >>
> >> >>> >> <?xml version='1.0' encoding='UTF-8'?>
> >> >>> >> <dataset>
> >> >>> >>   <postbox ID="1" SHORT_NAME="COR" MESSAGE_KEY="group.pbox.cor"/>
> >> >>> >>   <group_postbox ID="1"/>
> >> >>> >>
> >> >>> >>   <postbox ID="2" SHORT_NAME="CORINF"
> >> >>> >> MESSAGE_KEY="group.pbox.corinf"
> >> >>> >> PARENT_FK="1"/>
> >> >>> >>   <group_postbox ID="2"/>
> >> >>> >> </dataset>
> >> >>> >>
> >> >>> >> As it seems dbUnit does first all INSERT on table 'postbox' and
> >> >>> >> fails
> >> >>> >> (on
> >> >>> >> postbox id 2) because of a foreign key constraint.
> >> >>> >> The dataset is created as follows:
> >> >>> >> return new FlatXmlDataSet(new FileReader(baseDataFilename), false,
> >> >>> >> true,
> >> >>> >> false);
> >> >>> >>
> >> >>> >> Can anyone help me on this? How can I tell dbUnit 2.4.6 to first
> >> >>> >> things
> >> >>> >> first. Means first insert postbox 1 then group_post 1 after that
> >> >>> >> postbox 2
> >> >>> >> and finally group_postbox 2?
> >> >>> >> Thank you in advance.
> >> >>> >> Silvio
> >> >>> >>
> >> >>> >>
> >> >>> >>
> >> >>> >> ------------------------------------------------------------------------------
> >> >>> >> Let Crystal Reports handle the reporting - Free Crystal Reports
> >> >>> >> 2008
> >> >>> >> 30-Day
> >> >>> >> trial. Simplify your report design, integration and deployment -
> >> >>> >> and
> >> >>> >> focus
> >> >>> >> on
> >> >>> >> what you do best, core application coding. Discover what's new with
> >> >>> >> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> >> >>> >> _______________________________________________
> >> >>> >> dbunit-user mailing list
> >> >>> >> [hidden email]
> >> >>> >> https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >> >>> >>
> >> >>> >
> >> >>> >
> >> >>> >
> >> >>> >
> >> >>> > ------------------------------------------------------------------------------
> >> >>> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> >> >>> > 30-Day
> >> >>> > trial. Simplify your report design, integration and deployment - and
> >> >>> > focus
> >> >>> > on
> >> >>> > what you do best, core application coding. Discover what's new with
> >> >>> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> >> >>> > _______________________________________________
> >> >>> > dbunit-user mailing list
> >> >>> > [hidden email]
> >> >>> > https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >> >>> >
> >> >>> >
> >> >>>
> >> >>>
> >> >>>
> >> >>> ------------------------------------------------------------------------------
> >> >>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> >> >>> 30-Day
> >> >>> trial. Simplify your report design, integration and deployment - and
> >> >>> focus
> >> >>> on
> >> >>> what you do best, core application coding. Discover what's new with
> >> >>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> >> >>> _______________________________________________
> >> >>> dbunit-user mailing list
> >> >>> [hidden email]
> >> >>> https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >> >>
> >> >>
> >> >>
> >> >> ------------------------------------------------------------------------------
> >> >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> >> >> 30-Day
> >> >> trial. Simplify your report design, integration and deployment - and
> >> >> focus
> >> >> on
> >> >> what you do best, core application coding. Discover what's new with
> >> >> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> >> >> _______________________________________________
> >> >> dbunit-user mailing list
> >> >> [hidden email]
> >> >> https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >> >>
> >> >>
> >> >
> >> >
> >> > ------------------------------------------------------------------------------
> >> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> >> > 30-Day
> >> > trial. Simplify your report design, integration and deployment - and
> >> > focus on
> >> > what you do best, core application coding. Discover what's new with
> >> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> >> > _______________________________________________
> >> > dbunit-user mailing list
> >> > [hidden email]
> >> > https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >> >
> >>
> >>
> >> ------------------------------------------------------------------------------
> >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> >> 30-Day
> >> trial. Simplify your report design, integration and deployment - and focus
> >> on
> >> what you do best, core application coding. Discover what's new with
> >> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> >> _______________________________________________
> >> dbunit-user mailing list
> >> [hidden email]
> >> https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >
> >
> > ------------------------------------------------------------------------------
> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> > trial. Simplify your report design, integration and deployment - and focus
> > on
> > what you do best, core application coding. Discover what's new with
> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> > _______________________________________________
> > dbunit-user mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >
> >
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> dbunit-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>


_____________________________________________________________
DSL-Preisknaller: DSL-Komplettpakete von WEB.DE schon für
16,99 Euro/mtl.!* Hier klicken: http://produkte.web.de/go/02/


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Parent/Child constraint - Wrong insert order?

John Hurst-2
I wonder if this is the same as bug 2823084? (https://sourceforge.net/tracker/?func=detail&aid=2823084&group_id=47439&atid=449491) I am hoping to look at that one -- if this is the same I really ought to look at it. I really need to add some documentation and tests for these foreign key scenarios.

Please note that as well as the INSERT order for such cases of foreign keys, one also needs to consider the DELETE order, for the CLEAN_INSERT operation.

Way back in DbUnit 2.1 I submitted a patch to make the DELETE order correspond to the reverse order of first appearance of tables ... rather than simply deleting from bottom to top.

Thus if you have

<parent id="1"/>
<child id="A" parent="1"/>
<parent id="2"/>
<child id="B" parent="2"/>
<parent id="3"/>

The DELETE order for CLEAN_INSERT is:

DELETE FROM child;
DELETE FROM parent;

Which is necessary to avoid violating foreign key constraints.

Note that in this example it would be OK to INSERT either in order of items appearing in the file, or all parents first then all children. DELETE on the other hand, affecting all rows, must be done beginning with the child table.

Regards

John Hurst

On Wed, Nov 11, 2009 at 11:48 AM, Matthias Gommeringer <[hidden email]> wrote:
Hi guys,

I agree: it would be nice to have both columnSensing and kind of literal/verbose/ordered processing of the inserts, although I guess that it's not due to the column sensing since the parsed XML is grouped in ITable objects anyway (if I remember correctly that was also the case before the columnSensing feature was introduced). I think your initial approach to assume that the XML order is also used as the DB insert order is intuitive and natural and it actually should work this way. Could you submit a feature request for this?

rgds,
matthias

> -----Ursprüngliche Nachricht-----
> Von: "Roberto Lo Giacco" <[hidden email]>
> Gesendet: 10.11.09 15:20:28
> An: [hidden email]
> Betreff: Re: [dbunit-user] Issue with Parent/Child constraint - Wrong insert order?


> I would prefer if it were possible for you to talk about this with the
> developer who applied that change who, if I remember correctly, should
> be Sebastien.
>
> In any case it would be perfect in my opinion if we could have both
> features: column sensing AND statements order.
>
>
>    Roberto Lo Giacco
>
>
>
> On Mon, Nov 9, 2009 at 19:19, Silvio Wangler <[hidden email]> wrote:
> > Hi Roberto
> > Thank you very much for that answer. It proofs my analysis of today
> > since AbstractDataSet holds all table names in a OrderedTableNameMap und
> > the CachedDataSet returns a list of the map values (table names).
> > Is there any point within dbUnit where I could hook in to change this
> > behaviour? Should not there be a way to have XML datasets in the same way as
> > SQL scripts?
> > Best regards
> > Silvio
> >
> > 2009/11/9 Roberto Lo Giacco <[hidden email]>
> >>
> >> DbUnit statements are not executed in the same order they are listed
> >> in your dataset but they are grouped on a table basis.
> >>
> >> I don't remember why we changed this behavior and I'm not completely
> >> sure it happened on 2.2 release... may be this is related to the
> >> column sensing feature....
> >>
> >>   Roberto Lo Giacco
> >>
> >>
> >>
> >> On Mon, Nov 9, 2009 at 16:37, Silvio Wangler <[hidden email]>
> >> wrote:
> >> > Hi Luiz
> >> >
> >> > I am sorry. Let me describe the two tables to you.
> >> >
> >> > postbox
> >> > ------------
> >> > id // PK
> >> > parent_fk // optional FK to a parent postbox; refers to postbox(id).
> >> > If NULL it's a root postbox w/o parent
> >> >
> >> > group_postbox
> >> > ---------------------
> >> > id // PK refers to postbox(id)
> >> > (...) // and some additional values
> >> >
> >> > In the meantime I have downgraded my project to dbUnit 2.1. In 2.1
> >> > everything works as expected. If I upgrade to 2.2 it starts to fail.
> >> > If I change the dataset as you have suggested I get a constraint
> >> > violation (group_postbox --> postbox).
> >> >
> >> > Any clue what else can be done?
> >> >
> >> > Thank you und best regards
> >> > Silvio
> >> >
> >> > 2009/11/9 Luiz Eduardo Guida Valmont <[hidden email]>:
> >> >> Hi Silvio,
> >> >>
> >> >> From what I could learn of your dataset, you've got two tables: postbox
> >> >> and
> >> >> group_postbox; I guess postbox.parent_fk is a foreign key that refers
> >> >> to
> >> >> group_postbox.id (mainly because group_postbox seems to have no other
> >> >> attributes). That said, I thought that you might try the following
> >> >> dataset:
> >> >>
> >> >>> <?xml version='1.0' encoding='UTF-8'?>
> >> >>> <dataset>
> >> >>>   <!-- first, all group_postboxes -->
> >> >>>   <group_postbox ID="1"/>
> >> >>>   <group_postbox ID="2"/>
> >> >>>
> >> >>>   <!-- then the postboxes themselves -->
> >> >>>   <postbox ID="1" SHORT_NAME="COR" MESSAGE_KEY="group.pbox.cor"/>
> >> >>>   <postbox ID="2" SHORT_NAME="CORINF" MESSAGE_KEY="group.pbox.corinf"
> >> >>> PARENT_FK="1"/>
> >> >>> </dataset>
> >> >>
> >> >> Regards,
> >> >> Luiz
> >> >> 2009/11/9 Silvio Wangler <[hidden email]>
> >> >>>
> >> >>> Hi Luiz,
> >> >>>
> >> >>> Thank you for your quick answer.
> >> >>>
> >> >>> Well due to the DDL I think I cannot do that. group_postbox(id) refers
> >> >>> to postbox(id). Or isn't the order of my xml dataset as dbUnit
> >> >>> executes the inserts?
> >> >>>
> >> >>> 2009/11/9 Luiz Eduardo Guida Valmont <[hidden email]>:
> >> >>> > This is just a hunch, but here's my $0,02. Try grouping your
> >> >>> > group_postbox
> >> >>> > elements before the postbox ones. Your example shows a postbox short
> >> >>> > named
> >> >>> > "COR" as the very first element of the data set. Maybe that's the
> >> >>> > problem.
> >> >>> > Maybe.
> >> >>> >
> >> >>> > Regards,
> >> >>> > Luiz
> >> >>> >
> >> >>> > 2009/11/9 Silvio Wangler <[hidden email]>
> >> >>> >>
> >> >>> >> Hi everybody
> >> >>> >>
> >> >>> >> I am sure this question has been already asked in this mailing list
> >> >>> >> but
> >> >>> >> I
> >> >>> >> could find it yet. Currently I am troubling with a parent/child
> >> >>> >> relation and
> >> >>> >> cannot understand dbUnits behaviour.
> >> >>> >>
> >> >>> >> I am trying to insert the following dataset as FlatXmlDataSet using
> >> >>> >> dbUnit
> >> >>> >> 2.4.6.
> >> >>> >>
> >> >>> >> <?xml version='1.0' encoding='UTF-8'?>
> >> >>> >> <dataset>
> >> >>> >>   <postbox ID="1" SHORT_NAME="COR" MESSAGE_KEY="group.pbox.cor"/>
> >> >>> >>   <group_postbox ID="1"/>
> >> >>> >>
> >> >>> >>   <postbox ID="2" SHORT_NAME="CORINF"
> >> >>> >> MESSAGE_KEY="group.pbox.corinf"
> >> >>> >> PARENT_FK="1"/>
> >> >>> >>   <group_postbox ID="2"/>
> >> >>> >> </dataset>
> >> >>> >>
> >> >>> >> As it seems dbUnit does first all INSERT on table 'postbox' and
> >> >>> >> fails
> >> >>> >> (on
> >> >>> >> postbox id 2) because of a foreign key constraint.
> >> >>> >> The dataset is created as follows:
> >> >>> >> return new FlatXmlDataSet(new FileReader(baseDataFilename), false,
> >> >>> >> true,
> >> >>> >> false);
> >> >>> >>
> >> >>> >> Can anyone help me on this? How can I tell dbUnit 2.4.6 to first
> >> >>> >> things
> >> >>> >> first. Means first insert postbox 1 then group_post 1 after that
> >> >>> >> postbox 2
> >> >>> >> and finally group_postbox 2?
> >> >>> >> Thank you in advance.
> >> >>> >> Silvio
> >> >>> >>
> >> >>> >>
> >> >>> >>
> >> >>> >> ------------------------------------------------------------------------------
> >> >>> >> Let Crystal Reports handle the reporting - Free Crystal Reports
> >> >>> >> 2008
> >> >>> >> 30-Day
> >> >>> >> trial. Simplify your report design, integration and deployment -
> >> >>> >> and
> >> >>> >> focus
> >> >>> >> on
> >> >>> >> what you do best, core application coding. Discover what's new with
> >> >>> >> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> >> >>> >> _______________________________________________
> >> >>> >> dbunit-user mailing list
> >> >>> >> [hidden email]
> >> >>> >> https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >> >>> >>
> >> >>> >
> >> >>> >
> >> >>> >
> >> >>> >
> >> >>> > ------------------------------------------------------------------------------
> >> >>> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> >> >>> > 30-Day
> >> >>> > trial. Simplify your report design, integration and deployment - and
> >> >>> > focus
> >> >>> > on
> >> >>> > what you do best, core application coding. Discover what's new with
> >> >>> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> >> >>> > _______________________________________________
> >> >>> > dbunit-user mailing list
> >> >>> > [hidden email]
> >> >>> > https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >> >>> >
> >> >>> >
> >> >>>
> >> >>>
> >> >>>
> >> >>> ------------------------------------------------------------------------------
> >> >>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> >> >>> 30-Day
> >> >>> trial. Simplify your report design, integration and deployment - and
> >> >>> focus
> >> >>> on
> >> >>> what you do best, core application coding. Discover what's new with
> >> >>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> >> >>> _______________________________________________
> >> >>> dbunit-user mailing list
> >> >>> [hidden email]
> >> >>> https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >> >>
> >> >>
> >> >>
> >> >> ------------------------------------------------------------------------------
> >> >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> >> >> 30-Day
> >> >> trial. Simplify your report design, integration and deployment - and
> >> >> focus
> >> >> on
> >> >> what you do best, core application coding. Discover what's new with
> >> >> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> >> >> _______________________________________________
> >> >> dbunit-user mailing list
> >> >> [hidden email]
> >> >> https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >> >>
> >> >>
> >> >
> >> >
> >> > ------------------------------------------------------------------------------
> >> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> >> > 30-Day
> >> > trial. Simplify your report design, integration and deployment - and
> >> > focus on
> >> > what you do best, core application coding. Discover what's new with
> >> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> >> > _______________________________________________
> >> > dbunit-user mailing list
> >> > [hidden email]
> >> > https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >> >
> >>
> >>
> >> ------------------------------------------------------------------------------
> >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> >> 30-Day
> >> trial. Simplify your report design, integration and deployment - and focus
> >> on
> >> what you do best, core application coding. Discover what's new with
> >> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> >> _______________________________________________
> >> dbunit-user mailing list
> >> [hidden email]
> >> https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >
> >
> > ------------------------------------------------------------------------------
> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> > trial. Simplify your report design, integration and deployment - and focus
> > on
> > what you do best, core application coding. Discover what's new with
> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> > _______________________________________________
> > dbunit-user mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >
> >
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> dbunit-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>


_____________________________________________________________
DSL-Preisknaller: DSL-Komplettpakete von WEB.DE schon für
16,99 Euro/mtl.!* Hier klicken: http://produkte.web.de/go/02/


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user



--
Life is interfering with my game

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Parent/Child constraint - Wrong insert order?

saw303
In reply to this post by Matthias Gommeringer
Hi Matthias

Here is the feature request.

Best regards
Silvio

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Parent/Child constraint - Wrong insert order?

saw303
Sorry forgot to paste the link :)

https://sourceforge.net/tracker/?func=detail&aid=2896486&group_id=47439&atid=449494

2009/11/12 Silvio Wangler <[hidden email]>
Hi Matthias

Here is the feature request.

Best regards
Silvio


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user