nhibernate-envers
nhibernate-envers copied to clipboard
Add test for entity with lazy property
I get an error after updating NHibernate from 5.1.3 to 5.2.5
This error is during changes not lazy property in another session
Can you paste the exception/stack trace here please?
Message: NHibernate.PropertyValueException : Error dehydrating property value for NHibernate.Envers.Tests.NetSpecific.Integration.Lazy.EntityWithLazyProp_AUD.LazyProp ----> System.InvalidCastException : Unable to cast object of type 'NHibernate.Intercept.UnfetchedLazyProperty' to type 'System.String'.
at NHibernate.Persister.Entity.AbstractEntityPersister.Dehydrate(Object id, Object[] fields, Object rowId, Boolean[] includeProperty, Boolean[][] includeColumns, Int32 table, DbCommand statement, ISessionImplementor session, Int32 index) at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, Int32 j, SqlCommandInfo sql, Object obj, ISessionImplementor session) at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Object obj, ISessionImplementor session) at NHibernate.Action.EntityInsertAction.Execute() at NHibernate.Engine.ActionQueue.InnerExecute(IExecutable executable) at NHibernate.Engine.ActionQueue.ExecuteActions(IList list) at NHibernate.Engine.ActionQueue.ExecuteActions() at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session) at NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event) at NHibernate.Impl.SessionImpl.Flush() at NHibernate.Envers.Synchronization.AuditProcess.DoBeforeTransactionCompletion() in C:\GitHub\nhibernate-envers\Src\NHibernate.Envers\Synchronization\AuditProcess.cs:line 166
I get an error after updating NHibernate from 5.1.3 to 5.2.5
Do you mean that this test case worked in NHibernate + Envers before? Haven't looked closely but AFAIK, nothing regarding lazy props have changed recently. Could it be a change in NHib core that caused this maybe?
We have somthing like on this image

Left - NHib 5.1.3 and Rigth - NHib 5.2.5 Maybe it's a bug in NBib Core, but I cannot reproduce this error here, it's reproduced only with Envers.
And yes - it workes before
Maybe @hazzik has some input if this is a known bug or breaking change in later versions of nhib core?
Do you have any news?
No, I don't know. Lazy properties are handled just like normal properties in Envers.
Let's say you have an entity with this property...
<property name="LazyProp" lazy="true" />
...the audited entity that Envers creates behind the scenes have this corresponding property...
<property name="LazyProp" />
Nothing regarding this has been changed recently AFAIK. Guess the problem occurs when "moving" data from normal entity's lazy property to audited entity's non lazy property. But that's just a guess, cannot reproduce it.
Is it ok if I get ProxyForFieldInterceptor using NHib core, as it is in screenshot?
I'm not sure what the problem is but I believe the behavior you see is due to https://github.com/nhibernate/nhibernate-core/pull/1709. So yes changed type for proxy is expected behavior in 5.2 for entities with lazy properties.