It depend on how your audit obj look-like and on how you want manage a
possible exception during audit action (it rollback the original too ? ).

2008/12/1 Sean Carpenter <[EMAIL PROTECTED]>

> We're doing audit logging using NH 2.0 events as well, and using the
> event's Session (@event.Session) to do the audit logging.  It's working fine
> and shares the same transaction as the data modifications so commits and
> rollbacks work as expected.  I asked about this a while back on the list and
> the answer was that it's OK to use this session:
> http://groups.google.com/group/nhusers/browse_thread/thread/5aa4db0aba4dd139
>
>
> On Thu, Nov 27, 2008 at 9:49 AM, Oscar Orduz Acosta <[EMAIL PROTECTED]>wrote:
>
>> Thanks Ricardo:
>> Yes you're right, that was my firts try, but seems that its state is
>> closed, so it throws an error, and I can't find any way in Burrow to create
>> a temporary session.
>>
>>
>>
>> 2008/11/26 Ricardo Borges <[EMAIL PROTECTED]>
>>
>>
>>> Hum... You said that are using Burrow for session management but is
>>> calling OpenSession from the SessionFactory directly?
>>>
>>> @event.Session.SessionFactory.OpenSession()
>>>
>>> I think you should get the session from:
>>>
>>> ISession sess = new BurrowFramework().GetSession();
>>>
>>> don't you ?
>>>
>>>
>>>
>>> []'s
>>>
>>> Ricardo
>>>
>>>
>>> 2008/11/26 oorduz <[EMAIL PROTECTED]>:
>>> >
>>> > Hi,
>>> >
>>> > I have a project with Burrow for session management and I'm doing
>>> > audit log functionality, to do that I've code the OnPostUpdate,
>>> > OnPostDelete and OnPostInsert events (Nh 2.0).
>>> >
>>> > This project uses WCF, but the session is implemented by session-per-
>>> > request pattern like Web project. In the events I've created a
>>> > temporary session with a code like:
>>> > using (ISession tempSession = @event.Session.SessionFactory.OpenSession
>>> > ())
>>> > {
>>> >                    // Create audit log record
>>> >                    object obj = auditService.LogInsert(@event.entity,
>>> > newValues);
>>> >                    if (obj != null)
>>> >                    {
>>> >                        tempSession.Save(obj);
>>> >                        tempSession.Flush();
>>> >                    }
>>> > }
>>> >
>>> > In the start of request:
>>> >            new BurrowFramework().InitWorkSpace();
>>> >
>>> > In the end of request:
>>> >            new BurrowFramework().CloseWorkSpace();
>>> >
>>> >
>>> > The problem: When I close the session (In the end of request) and some
>>> > error occurs in the Db (Something like FK restriction) all transaction
>>> > rollback EXCEPT the audit log!!
>>> >
>>> > Did I make some mistake to share transaction scope? Someone has
>>> > implemented this functionality with Burrow?
>>> >
>>> > Thanks in advance
>>> >
>>> > Oscar
>>> >
>>> > >
>>> >
>>>
>>>
>>>
>>
>>
>>
>
> >
>


-- 
Fabio Maulo

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to