Is it possible to group records belonging to an entity in dbunit?

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

Is it possible to group records belonging to an entity in dbunit?

Joshua Daniel-2

Hi,

Our JPA entity model auto-generates primary key identifiers for user, user_address tables. Would it be possible to group these entities given below via dbunit, so that I don't need to provide neither the primary key as well as the foreign key reference from user_address.user_id. It is getting very hard to maintain these keys (i.e. I would prefer to group the primary record 'user' and the child records 'user_address' so that dbunit can group them automatically by looking up the entity metadata). Is it achievable?

<user id="1" first_name="Josh" creation_date="2009-07-11 15:45:28"/>

<user_address id="1" user_id="1" address="Main St" city="Los Angeles"/>

I would prefer something like this

<!-- First user -->

<user first_name="Josh" creation_date="2009-07-11 15:45:28"/>

<user_address address="Main St" city="Los Angeles"/>

<!-- Second user -->

<user first_name="Mary" creation_date="2009-07-11 15:45:28"/>

<user_address address="Taylors St" city="San Jose"/>

Thanks,

- Joshua


------------------------------------------------------------------------------

_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to group records belonging to an entity in dbunit?

Jeff Jensen-2

It’s not possible that I am aware of.

 

Describe what you mean by “very hard to maintain these keys” – how?  For examples, do the dataset files have lots of rows in them?  Is the file(s) shared across many tests?  Do subsequent tests depend on row results of prior tests?

 

I am also wondering because the organization of the dataset files can really help or hinder.  In my experience, keeping tests isolated and separate files per test works best, and really helps limit the number of rows and tables per file.  I’ve also successfully shared a few common dataset files across tests – as “prep/seed” datasets, inserted before each test.  But again, each file isn’t huge this way.

 

 

From: Joshua Daniel [mailto:[hidden email]]
Sent: Sunday, April 25, 2010 11:25 PM
To: [hidden email]
Subject: [dbunit-user] Is it possible to group records belonging to an entity in dbunit?

 

Hi,

Our JPA entity model auto-generates primary key identifiers for user, user_address tables. Would it be possible to group these entities given below via dbunit, so that I don't need to provide neither the primary key as well as the foreign key reference from user_address.user_id. It is getting very hard to maintain these keys (i.e. I would prefer to group the primary record 'user' and the child records 'user_address' so that dbunit can group them automatically by looking up the entity metadata). Is it achievable?

<user id="1" first_name="Josh" creation_date="2009-07-11 15:45:28"/>

<user_address id="1" user_id="1" address="Main St" city="Los Angeles"/>

I would prefer something like this

<!-- First user -->

<user first_name="Josh" creation_date="2009-07-11 15:45:28"/>

<user_address address="Main St" city="Los Angeles"/>

<!-- Second user -->

<user first_name="Mary" creation_date="2009-07-11 15:45:28"/>

<user_address address="Taylors St" city="San Jose"/>

Thanks,

- Joshua


------------------------------------------------------------------------------

_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to group records belonging to an entity in dbunit?

Joshua Daniel-2
Hi Jeff,

We use the dataset files to populate the seed data as well as test data. Most of the data needed by a module is present in a single data file and any addition of a new row in a table needs that we provide the primary key in a sequential fashion and it has to be associated properly in the child tables. It becomes more problematic if you have to insert a new row somewhere in between the existing rows in a table, which causes all subsequent primary id(s) to be re-written. Sometimes there is also a overlap between the primary key(s) in seed data as well as test data (Should I move the test data to a completely different key range to avoid these collisions). I am just looking for best practices to manage these files.

Thanks,
- Joshua

On Mon, Apr 26, 2010 at 10:06 AM, Jeff Jensen <[hidden email]> wrote:

It’s not possible that I am aware of.

 

Describe what you mean by “very hard to maintain these keys” – how?  For examples, do the dataset files have lots of rows in them?  Is the file(s) shared across many tests?  Do subsequent tests depend on row results of prior tests?

 

I am also wondering because the organization of the dataset files can really help or hinder.  In my experience, keeping tests isolated and separate files per test works best, and really helps limit the number of rows and tables per file.  I’ve also successfully shared a few common dataset files across tests – as “prep/seed” datasets, inserted before each test.  But again, each file isn’t huge this way.

 

 

From: Joshua Daniel [mailto:[hidden email]]
Sent: Sunday, April 25, 2010 11:25 PM
To: [hidden email]
Subject: [dbunit-user] Is it possible to group records belonging to an entity in dbunit?

 

Hi,

Our JPA entity model auto-generates primary key identifiers for user, user_address tables. Would it be possible to group these entities given below via dbunit, so that I don't need to provide neither the primary key as well as the foreign key reference from user_address.user_id. It is getting very hard to maintain these keys (i.e. I would prefer to group the primary record 'user' and the child records 'user_address' so that dbunit can group them automatically by looking up the entity metadata). Is it achievable?

<user id="1" first_name="Josh" creation_date="2009-07-11 15:45:28"/>

<user_address id="1" user_id="1" address="Main St" city="Los Angeles"/>

I would prefer something like this

<!-- First user -->

<user first_name="Josh" creation_date="2009-07-11 15:45:28"/>

<user_address address="Main St" city="Los Angeles"/>

<!-- Second user -->

<user first_name="Mary" creation_date="2009-07-11 15:45:28"/>

<user_address address="Taylors St" city="San Jose"/>

Thanks,

- Joshua


------------------------------------------------------------------------------

_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user



------------------------------------------------------------------------------

_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user