openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christopher Cudennec" <Smutje...@gmx.net>
Subject Why SaveFieldManager without state? (Auditing)
Date Wed, 14 Sep 2011 14:23:01 GMT
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

Mime
View raw message