Hibernate Version 2.1.3
I'm trying to work this out, have read through everything I can lay my hands on and am still trying to work out an ideal solution to this problem - I don't want any object in my session (whether new or loaded) to be updated without my explicitly calling save or update for that specific object.
I have objects that rely on data that is created by triggers in the database which needs to be immediately available, so when they are explicitly saved I need to flush the session and do a refresh to reload the data into the object <i>but I don't want any other modified objects to be written to the database when I call the flush</i>.
I've looked into using the ILifecycle OnUpdate callback but it's not called unless an explicit update is done, so I can't use the veto there, and the Interceptor approach doesn't let you veto.
My fallback is looking like having to create a internal field to replicate each field accessor that NHibernate uses, create a save method for each of my objects and have an interceptor copy the fields from the internal replicas to the NHibernate fields on save or update and vice versa on load. Mind you, I think this is a nasty kludge.
Are there any alteratives anyone can suggest?
Cheers,
Symon.
|