Hi Armin,
Well here is a snippet.....
Basic idea is a TestCaseHelper class, which is called by a junit TestCase and
handles the setUp/tearDown for the TestCase. The object wrapping the PB is
created in the TestCaseHelper, then passed back to the testCase for use in its
test methods (eg complex searches etc). So, it is the TestCaseHelper class
that initiates the create/update/delete ops - create/update done in setUp, and
delete in tearDown.
roughly this translates to:
public void setUp() {
//create a bunch of objects.....
//add them to a Collection.....
//pass to a wrapper class which uses a PB to create each in turn
//do a few object modifications....
//then call 'update' on the wrapper class (uses PB.store with an
ObjectModification.needsUpdate())...
}
public void tearDown() {
//just calls delete via the wrapper class on each object in correct order...
}
The wrapper class does straight delegation to the PB for update/delete; the
only other level of complexity is that the wrapper 'create' method taking a
Collection calls PB.store() for each item in turn, *but* the iterator itself
is run within a transaction, ie
pb.begin();
Iterator it = collection.iterator();
while(it.hasNext()) {
pb.store(it.next());
}
pb.commit();
That's it, basically. The db fill code isn't any more complex really - just
creates a bunch of objects, stores them then retrieves them and updates them
with extra relationships.
Not sure if that helps!!
cheers,
Chris
Armin Waibel wrote:
> Strange!?
>
> Could you post a some sample code or
> a small test case?
>
> regards,
> Armin
>
--
To unsubscribe, e-mail: <mailto:ojb-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>