Hi Andrus
I figured that validateForInsert was my option, and works quite well.
I was trying to clean up one of my projects for 3.0 and hence trying
to switch all the overrides to callbacks.
The scenario is exactly as you described. I'm working on real estate
software internally it manages a number of properties, some of which
can be advertised on the web site. A property can be in either "on
market" or "not on market" state and the property can be either
"advertised" or "not advertised" state.
And, although the property can be on the market and not advertised on
the site, it can not be advertised on the site without being on the
market.
Hence during commit I need to check that the user has not taken the
property of the market and if he/she has then I need to automatically
set the state to "not advertised".
I hope this makes some sense! But no stress I'll just use the
validateForInsert method.
Thank you!
Gary
On 10/17/07, Andrus Adamchik <andru..bjectstyle.org> wrote:
> We followed JPA spec and implemented PRE_PERSIST to be called when a
> new object is registered with the context (i.e. prior to
> 'commitChanges'). So you you are right - there is no callback for the
> new objects right before 'commit'.
>
> I suspect there are cases when this is not sufficient (i.e. when you
> need to change object state based on some other objects state that is
> only available on commit)... BTW, could you describe your scenario
> when you need such callback? Maybe there are other ways around.
>
> Also as a temporary workaround you can use the old "callback"
> CayenneDataObject.validateForInsert()
>
> Andrus
>
>
> On Oct 17, 2007, at 6:18 AM, Gary Jarrel wrote:
>
> > Hi Guys
> >
> > This maybe a silly question, but is there a callback type which would
> > be fired before a new record is inserted into the database during the
> > call to commitChanges()? Doesn't seem like PRE_PERSIST or PRE_UPDATE
> > does the trick?
> >
> > Maybe I'm just missing something with these whole callbacks business?
> >
> > Cheers,
> >
> > Gary
> >
>
>
This archive was generated by hypermail 2.0.0 : Wed Oct 17 2007 - 03:59:17 EDT