You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by Andrus Adamchik <an...@objectstyle.org> on 2009/11/01 12:24:00 UTC

Re: Making sense of callbacks

On Oct 30, 2009, at 11:21 PM, Lachlan Deck wrote:

> I refactored these (after the jar update) to postAdd (when noticing  
> that it wasn't working anymore .. and checked the mail archives for  
> what Andrus had committed) ... and found that things weren't working  
> either way until I rolled back the jar update.

Actually no refactoring should is needed. Just open the model in the  
new CayenneModeler and agree to perform an upgrade. It will remap (in  
the XML) the existing Java method names to the right callbacks. Or do  
you configure callbacks in the code, not the model?

Andrus


Re: Making sense of callbacks

Posted by Lachlan Deck <la...@gmail.com>.
On 02/11/2009, at 2:23 PM, Andrey Razumovsky wrote:

> So you've not configured callbacks in model - have you added callbacks
> through LifecycleCallbackRegistry or something? Could you give a  
> snippet?
> Could you ensure that both prePersist and postAdd callbacks are  
> invoked
> (e.g. add a breakpoint there). My test above shows it must be so.

Here's what I've done to test this.
-- without upgrading --
1) create record(s) on client
2) commit changes
3) logger.warn.... server.Contact#prePersist called
4) logger.warn.... server.Contact#validateForSave called
5) all saved, good.

-- after upgrade --
1) add method postAdd() to server.Contact with a logger.warn
2) create record(s) on client
3) commit changes
4) logger.warn.... server.Contact#validateForSave
5) fails validation

No lifecycle events fired after upgrade on either prePersist  
(obviously as validation failed) or postAdd.

with regards,
--

Lachlan Deck




Re: Making sense of callbacks

Posted by Lachlan Deck <la...@gmail.com>.
Ugh -- sorry all.

We did have some custom code handling this after all that needed  
updating. So on initial test it seems fine.

On 02/11/2009, at 2:23 PM, Andrey Razumovsky wrote:

> So you've not configured callbacks in model - have you added callbacks
> through LifecycleCallbackRegistry or something? Could you give a  
> snippet?
> Could you ensure that both prePersist and postAdd callbacks are  
> invoked
> (e.g. add a breakpoint there). My test above shows it must be so.
>
> 2009/11/2 Lachlan Deck <la...@gmail.com>
>
>> On 01/11/2009, at 10:24 PM, Andrus Adamchik wrote:
>>
>>
>>> On Oct 30, 2009, at 11:21 PM, Lachlan Deck wrote:
>>>
>>> I refactored these (after the jar update) to postAdd (when  
>>> noticing that
>>>> it wasn't working anymore .. and checked the mail archives for  
>>>> what Andrus
>>>> had committed) ... and found that things weren't working either  
>>>> way until I
>>>> rolled back the jar update.
>>>>
>>>
>>> Actually no refactoring should is needed. Just open the model in  
>>> the new
>>> CayenneModeler and agree to perform an upgrade. It will remap (in  
>>> the XML)
>>> the existing Java method names to the right callbacks. Or do you  
>>> configure
>>> callbacks in the code, not the model?
>>>
>>
>> Yeah - we've not configured any callbacks in the Model. Just accept  
>> the
>> default behaviour... so our code obviously needed adjusting  
>> prePersist() ->
>> postAdd().
>>
>> with regards,
>> --
>>
>> Lachlan Deck
>>
>>
>>
>>
>
>
> -- 
> Andrey

with regards,
--

Lachlan Deck




Re: Making sense of callbacks

Posted by Andrey Razumovsky <ra...@gmail.com>.
So you've not configured callbacks in model - have you added callbacks
through LifecycleCallbackRegistry or something? Could you give a snippet?
Could you ensure that both prePersist and postAdd callbacks are invoked
(e.g. add a breakpoint there). My test above shows it must be so.

2009/11/2 Lachlan Deck <la...@gmail.com>

> On 01/11/2009, at 10:24 PM, Andrus Adamchik wrote:
>
>
>> On Oct 30, 2009, at 11:21 PM, Lachlan Deck wrote:
>>
>>  I refactored these (after the jar update) to postAdd (when noticing that
>>> it wasn't working anymore .. and checked the mail archives for what Andrus
>>> had committed) ... and found that things weren't working either way until I
>>> rolled back the jar update.
>>>
>>
>> Actually no refactoring should is needed. Just open the model in the new
>> CayenneModeler and agree to perform an upgrade. It will remap (in the XML)
>> the existing Java method names to the right callbacks. Or do you configure
>> callbacks in the code, not the model?
>>
>
> Yeah - we've not configured any callbacks in the Model. Just accept the
> default behaviour... so our code obviously needed adjusting prePersist() ->
> postAdd().
>
> with regards,
> --
>
> Lachlan Deck
>
>
>
>


-- 
Andrey

Re: Making sense of callbacks

Posted by Lachlan Deck <la...@gmail.com>.
On 01/11/2009, at 10:24 PM, Andrus Adamchik wrote:

>
> On Oct 30, 2009, at 11:21 PM, Lachlan Deck wrote:
>
>> I refactored these (after the jar update) to postAdd (when noticing  
>> that it wasn't working anymore .. and checked the mail archives for  
>> what Andrus had committed) ... and found that things weren't  
>> working either way until I rolled back the jar update.
>
> Actually no refactoring should is needed. Just open the model in the  
> new CayenneModeler and agree to perform an upgrade. It will remap  
> (in the XML) the existing Java method names to the right callbacks.  
> Or do you configure callbacks in the code, not the model?

Yeah - we've not configured any callbacks in the Model. Just accept  
the default behaviour... so our code obviously needed adjusting  
prePersist() -> postAdd().

with regards,
--

Lachlan Deck