You have full power to do what you need but not using an interceptor.You should use event/listeners feature. There you will have more information and the SessionFactory to open a new session or statelesssession. event/listeners feature give you full power to do whatever you want even overriding NH default behavior.
2009/2/9 mantzas <[email protected]> > > Fabio, > > this is the way to process a IAuditable object in case it is saved. > > My approach is another. > > If the session has a interceptor the i wish to audit my entity > objects. > This means whenever one of my objects get saved, updated or deleted i > wish to create a new entity that will be saved along with it. > > This means that i need a session object inside my interceptor in order > to save this new entity. > > Lets say the this new entity is: > > AuditDataClass > > Id int > Type string { "insert","update","delete" } > Timestamp datetime > Data string (The data contains all properties of the > original Entity lets say customer that are changed i.e. {PropertyName: > oldvalue, newvalue} for every changed property ). > User Int. > > The concept is this. > > 1. I update the Customer entity. > 2. The interceptor catches the appropriate "event" and creates this > AuditData object > 3. The Interceptor saves this object to the db. > 4. The point is that the customer object gets saved along with this > AuditData object just by using the intercepted session and of course > in a transactional manner. > > Can this be done in the Interceptor??? (i didnt find a session object > in there only set session.) > > I hope this is clearer now. > > Regards, > > Mantzas > > On Feb 8, 9:51 pm, Fabio Maulo <[email protected]> wrote: > > http://nhforge.org/doc/nh/en/index.html#manipulatingdata-interceptors > > > > 2009/2/8 mantzas <[email protected]> > > > > > > > > > > > > > Hi, > > > > > is there a way for using IIinterceptor to write a audit entity to the > > > database? > > > > > Say i have a Entity named AuditData that is mapped to the database. > > > > > AuditData Class has the following properties: > > > > > int Id > > > string Data > > > > > where Data contains the changes to a Business Entity. > > > > > This way i want to create a new AuditData object and persist it to the > > > database through the session. > > > > > Is there a way to do this using the IInterceptor? > > > > -- > > Fabio Maulo > > > -- 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 -~----------~----~----~----~------~----~------~--~---
