Hi,
I tried it, but it doesn't work :-( See my code below. I tried it with an empty array, or with an array of the length of the properties, but none of them worked :-( When I debug we pass into the correct part of the method, but still the update to the database happens...
Any idea?
Thanks a lo in advance,
Pieter
My code of the interceptor:
Option Explicit On
Imports NHibernate
Imports NHibernate.Cfg
Public Class NHibernateInterceptor
Inherits EmptyInterceptor
Public Overrides Function FindDirty(ByVal entity As Object, ByVal id As Object, ByVal currentState() As Object, ByVal previousState() As Object, ByVal propertyNames() As String, ByVal types() As NHibernate.Type.IType) As Integer()
'when we are loading an object and some of it's properties are changed: we don't want to have it saved automaticly to the database!
If CType(entity, BaseClass).IsDoingLoad Then
'in this case we have to return an empty array of integers
'Dim intA(propertyNames.Length - 1) As Integer
Dim intA(-1) As Integer
Return intA
Else
'normal case: 'call the MyBase
Return MyBase.FindDirty(entity, id, currentState, previousState, propertyNames, types)
End If
End Function
Public Overrides Function OnLoad(ByVal entity As Object, ByVal id As Object, ByVal state() As Object, ByVal propertyNames() As String, ByVal types() As NHibernate.Type.IType) As Boolean
Dim MyBaseClass As BaseClass = CType(entity, BaseClass)
'method which has to be executed when an object is Loaded from the database
MyBaseClass.BeforeLoad()
'call the MyBase
Return MyBase.OnLoad(entity, id, state, propertyNames, types)
End Function
End Class
|