Hi Alex,
Yes you can do that. Validation routine is executed before object
changes are finalized, allowing arbitrary object operations to be
performed during the validation.
Andrus
On Jan 17, 2007, at 12:07 AM, Alexander Lamb (dev) wrote:
Hello list,
I am currently using Cayenne 2.0.
I read it was possible to modify objects during a validateForInsert
or validateForSave call (e.g. not the same as old WebObjects).
What about creating a new object and inserting it in the
DataContext? Will it get saved at the same time?
My problem is the following:
I have an object which has a to-one relationship to another object.
That other object has to be created at the same time as the first
one. I would like to make it automatic so the user of the library I
am writing can simply create and insert the first object and the
second one will follow.
To understand why I am creating two objects related one-to-one it
is because I have an entity which can be related (to-one) to either
one of four other entities. I am doing this instead of modeling
things with a class hierarchy since cayenne doesn't support
multiple tables class hierarchies.
Thanks for any hints!
Alex