All work
Support saving an object with proxied envers collection
Description
Environment
Attachments
Activity
Tobias Wolschon October 2, 2012 at 1:57 PM
Unfortunally, this does not help here, because our own Save method (which calls SaveOrUpdate) neither has a ref parameter nor returns the saved object. Changing the signature (and a lot of usages) would be our solution, if there won't be a fix for this issue.
Roger October 2, 2012 at 1:23 PM
Btw, if you don't know already (and maybe it doesn't help you anyway but)...
<< ...because Merge does not modify the passed object...>>
The object Merge() returns reflects the changes and is attached to the session.
Tobias Wolschon October 2, 2012 at 12:42 PM
OK, I will be watching your question. Thank you.
Roger October 2, 2012 at 12:23 PM
This is two bugs in one. The one throwing cast exception can quite easily be fixed (envers collections needs to implement both the generic interface and the non generic interface). However, doing this will only make those test fail in the same way as your other tests. And that problem I don't really think is solvable without changing NH Core.
The "old state" of the detached collection that's needed for Envers to know what has been changed isn't available - nor should it be I think. The thing that needs to be changed in NH Core (I think) is provide enough info in its event listeners so Envers can refetch the orginal collection from db at persist time.
I posted a question to the NH Core team here that you can follow
https://groups.google.com/forum/?fromgroups=&hl=en#!topic/nhibernate-development/xOlg2hD3kmg
Tobias Wolschon October 2, 2012 at 9:27 AM
We encountered some incorrect revision data again. An entity's collection gets fully replaced before a call to SaveOrUpdate, that will generate the invalid data in the audit tables (I saw old rows, where the revend is not set, but it should be). Replacing the call to SaveOrUpdate with Merge at this place would cause a breaking change in our database library, because Merge does not modify the passed object. It would be great, if we can avoid that.
Do you already have any ideas for resolving this issue?
There are some problems when saving an object, that is loaded from the audit tables.
We have an entity with a one-to-many (unidirectional) relationship and cascading enabled. Saving such an object from the normal tables works fine as expected. However, if the object is loaded from the audit tables, saving it will create an invalid revision. I will attach some tests, that will demonstate this issue.