The previous poster is correct.
When updating/inserting new objects, we want to use stored procedures that will create and maintain history on particular tables. 'PACKAGE' and 'COMPONENT'.
When inserting/updating PACKAGE or COMPONENT, our sprocs have all the fields defined + one parameter at the end "USER_ID" which is to be fed the Thread.CurrentPrincipal.Identity.Name string.
In order to do this effectively, somekind of db interception is needed, at a much lower level than IInterceptor and ILifecycle provide.
I'm curious if the newer Hibernate 3 is considering this usage pattern?
As for implementation, I'm going to have the session or sessionfactory have a IDbInterceptor property that the IBatcher will call if not null.
Initially I see IDbInterceptor's interface as:
Code:
using System.ComponentModel;
using System.Data;
namespace NHibernate
{
public interface IDbInterceptor
{
void OnCreate(IDbCommand command, CancelEventArgs e)
void OnUpdate(IDbCommand command, CancelEventArgs e)
void OnDelete(IDbCommand command, CancelEventArgs e)
void OnSelect(IDbCommand command, CancelEventArgs e)
}
}
The IBatcher implementation (NonBatchingBatcher) will check the current session for IDbInterceptor just before executing the command on the connection.
I would assume the NHibernate (and Hibernate team) may be interested in this, if so, just contact me at
ensoft@enewtonenterprises.com. I will also make a formal request to add this code into the NHibernate branch.
Lets discuss this a bit so it can meet developers' needs.
(Somebody else will have to do the java port and test it)