nhibernate-envers icon indicating copy to clipboard operation
nhibernate-envers copied to clipboard

Add test for entity with lazy property

Open ogorodnikovInfopulse opened this issue 6 years ago • 10 comments
trafficstars

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

ogorodnikovInfopulse avatar May 23 '19 12:05 ogorodnikovInfopulse

Can you paste the exception/stack trace here please?

RogerKratz avatar May 23 '19 12:05 RogerKratz

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'.

ogorodnikovInfopulse avatar May 23 '19 12:05 ogorodnikovInfopulse

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

ogorodnikovInfopulse avatar May 23 '19 12:05 ogorodnikovInfopulse

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?

RogerKratz avatar May 23 '19 13:05 RogerKratz

We have somthing like on this image 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

ogorodnikovInfopulse avatar May 23 '19 14:05 ogorodnikovInfopulse

Maybe @hazzik has some input if this is a known bug or breaking change in later versions of nhib core?

RogerKratz avatar May 23 '19 15:05 RogerKratz

Do you have any news?

ogorodnikovInfopulse avatar May 28 '19 06:05 ogorodnikovInfopulse

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.

RogerKratz avatar May 29 '19 15:05 RogerKratz

Is it ok if I get ProxyForFieldInterceptor using NHib core, as it is in screenshot?

ogorodnikovInfopulse avatar May 30 '19 06:05 ogorodnikovInfopulse

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.

bahusoid avatar Jun 04 '19 14:06 bahusoid