I've done it two different ways in the past depending on what was
available in Cayenne at the time. Since Cayenne supports optimistic
locking (and thus already stores the previous old value somewhere),
getting the old value isn't that big a deal.
In Cayenne 1, I used code generation templates and had the
create<entity> and set<attribute> methods automatically create log
records. It didn't handle many-to-many relationships very well since
I didn't know enough back then to use them :-)
In Cayenne 2, I used a hook to intercept these at a lower level and
built the values. I don't remember if there were any limitations on
that code.
I think the code for the Cayenne 2 method is in the bug tracker.
Cayenne 3 might handle it better with a lifecycle callback.
On Tue, Feb 10, 2009 at 6:19 PM, Laurent Marchal <contac..enux.fr> wrote:
> Yeah i agree that table/field/date/old value/new value is clearer, but it
> seems complex to me to have old/new values.
>
> Do you found a good way to do this ?
>
> Mike Kienenberger wrote:
>>
>> If you want the sql executed, query logger seems like it might be your
>> best best.
>>
>> For what it's worth, we occasionally need to go through our audit logs
>> to research why something changed, and if we had to work with raw sql,
>> it'd be pretty hopeless. Breaking things out into
>> table/field/date/old value/new value/source-of-change-identity makes
>> things a lot better.
>>
>> On Tue, Feb 10, 2009 at 6:05 PM, Laurent Marchal <contac..enux.fr> wrote:
>>
>>>
>>> Hello there,
>>>
>>> In our product we need to audit all the database modifications (creates,
>>> updates, deletes) and log them in an audit table. I see some olds posts
>>> in
>>> the ML about that and there are solutions for that in cayenne. But i
>>> would
>>> like to know if somebody have some hints about the best way to implement
>>> it
>>> with cayenne.
>>>
>>> As we need to store the raw SQL query executed, should we use
>>> QueryLogger,
>>> TransactionDelegate, DataContextDelegate, Lifycle listeners ?
>>>
>>> Thanks.
>>>
>>> Laurent
>>>
>>>
>
This archive was generated by hypermail 2.0.0 : Tue Feb 10 2009 - 18:30:50 EST