You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Christopher Cudennec <Sm...@gmx.net> on 2011/09/14 16:23:01 UTC

Why SaveFieldManager without state? (Auditing)

Hi everyone!

Inspired by Pinaki Poddar's blog about auditing I try to implement an auditing facility. I came across some weird (at least for me ;)) behaviour when using the SaveFieldManager to access the old state of an object: getState() returns 'null'. Why is that?

I get the 'null' state in the following situation:
Class A has a list of class B.
I add an instance of B to A's list.

I get a notification in my @PreUpdate method that A was changed. But when I ask the SaveFieldManager for the old state I get 'null'.

I saw that StaetManagerImpl creates an instance of my SaveFieldManager passing 'null' as a parameter:

Line 2828 of that class look like this:

> // don't bother creating the save field manager if we're not going to
> // save the old field value anyway
> if (_saved == null) {
>   if (_loaded.get(field))
>     _saved = new SaveFieldManager(this, null, _dirty);
>   else
>     return;
> }

I know using some non-public classes from the kernel might go along with new problems. On the other hand I like the approach described in the blog.

I use OpenJPA 2.1.0.

Any recommendations or hints?

Cheers,

Christopher
-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de

Re: Why SaveFieldManager without state? (Auditing)

Posted by Christopher Cudennec <Sm...@gmx.net>.
Hi Pinaki!

Thanks for mentioning the RestoreState! I read your blog but might have 
forgotten the property anyway. I'll let you know as soon as I am back in 
my office!

I read about the new auditing facility only recently when I had already 
set up my services. I guess I'll check the latest changes in OpenJPA 
2.2.* to see if it fits my needs. Actually I tried not to use the 
snapshot release because the auditing facility is meant to be used in a 
productive project soon. On the other hand the changes look very 
promising :).

Cheers,

Christopher

Am 14.09.2011 19:11, schrieb Pinaki Poddar:
> Hi Christopher,
>    Noticed that auditing is a favorite topic, we have added a new audit
> capability [1] in OpenJPA.
> To answer your question, did you read the last two lines of my blogs -- it
> mentions a RestoreState flag.
>
> [1]
> http://openjpa.208410.n2.nabble.com/OpenJPA-Audit-Facility-tc6722915.html
>
>
>
> -----
> Pinaki Poddar
> Chair, Apache OpenJPA Project
> --
> View this message in context: http://openjpa.208410.n2.nabble.com/Why-SaveFieldManager-without-state-Auditing-tp6792743p6793537.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Why SaveFieldManager without state? (Auditing)

Posted by Pinaki Poddar <pp...@apache.org>.
Hi Christopher,
  Noticed that auditing is a favorite topic, we have added a new audit
capability [1] in OpenJPA.
To answer your question, did you read the last two lines of my blogs -- it
mentions a RestoreState flag.  

[1]
http://openjpa.208410.n2.nabble.com/OpenJPA-Audit-Facility-tc6722915.html



-----
Pinaki Poddar
Chair, Apache OpenJPA Project
--
View this message in context: http://openjpa.208410.n2.nabble.com/Why-SaveFieldManager-without-state-Auditing-tp6792743p6793537.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.