-
1. Re: Deleted entities with null properies - WHY?
adamw Mar 19, 2009 7:59 AM (in response to agorski)Hello,
the reason is because the revision stores the "current" state, as it was at that revision; when you delete an entity, it has no state (as its deleted). The solution to your problem would be to audit ADD and DEL actions (not MOD actions) (so just install insert/delete listeners, not the update ones). Then, the history of each entity would have 1 or 2 entries, and the first entry would hold the original data.
Adam -
2. Re: Deleted entities with null properies - WHY?
agorski Mar 19, 2009 8:12 AM (in response to agorski)Hi,
I cannot use first entry to solve my problem - entry could change during its live and for me important is only last state of the entry (actual shortly before delete).
Of course there is a way around to keep MOD entries and after delete remove all MOD except newest one but this solution is dirty.
You said revision stores "current" state - I think listeners are connected to Post(Remove/Create/Update) actions - maybe for the delete action would be better to connect listener with PreRemove ?
Albert -
3. Re: Deleted entities with null properies - WHY?
adamw Mar 19, 2009 8:25 AM (in response to agorski)Hello,
ah yes, you are right of course. Then it's a simple code change, if you look at the envers code (AuditEvenListener). I think you simple need to schedule ModWorkUnit instead of a DelWorkUnit in the on delete listener.
Adam -
4. Re: Deleted entities with null properies - WHY?
agorski Mar 19, 2009 8:52 AM (in response to agorski)Hello,
of course I can change the code but still remains the question if it is only my problem/wish or general one.
I think it would be much better to keep last state before delete in opposite to keep only ID of removed entity.
The problem with keeping only ID is much deeper: imagine that you logging only DEL events. You are not able to query/filter your data unless you use ID (from user perspective unacceptable). What more even if you find audit data it keeps only information when entry was removed.
regards,
Albert -
5. Re: Deleted entities with null properies - WHY?
adamw Mar 19, 2009 1:22 PM (in response to agorski)Hello,
maybe it can be a configuration option. Normally I think it's not desired (if you audit all events), as then the last state would be duplicated in the last mod revision and the del revision.
But in fact, maybe adding this as an option isn't a bad idea. I could also add a section to the manual describing how you can audit only certain types of events.
If you still support the idea, please create a jira feature request :). Maybe also some other users will give feedback?
Adam -
6. Re: Deleted entities with null properies - WHY?
kaizersh Mar 21, 2009 9:56 AM (in response to agorski)Hi,
I'd made a post sometime back regarding the same thing. It would actually be good to have the option to store the fields of the entity to be deleted in the audit table. We have a scenario where we would need to retrieve the state of an entity as it existed at time of deletion. Currently, I would have to get the state based on the last modified revision.
Thanks.
Regards
Kaizer -
7. Re: Deleted entities with null properies - WHY?
adamw Mar 21, 2009 1:55 PM (in response to agorski)Ok, great, that's two votes :) Please create a feature request in JIRA.
Adam -
8. Re: Deleted entities with null properies - WHY?
agorski Mar 21, 2009 7:26 PM (in response to agorski)Hi,
already done:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3819
Have a nice implementation :)
Albert -
9. Re: Deleted entities with null properies - WHY?
adamw Mar 23, 2009 10:52 AM (in response to agorski)Thanks ;)
Remember that contributions are always welcome and often speed up significantly introducing a new feature ;)
Adam