Bump!

I really don't know what to do about this, and I've been unable to
make any further progress on the issue.

Any ideas, anyone?

Paul Batum

On Feb 3, 11:13 am, Paul Batum <[email protected]> wrote:
> Hi all,
>
> I am having trouble with usingstatelesssessionto perform updates.
> Basically, the problem is that during the generation of the prepared
> statement for the update, NH tries to read the version from a proxy,
> and I get the "proxies cannot be fetched by astatelesssession"
> error.
>
> My code is something along these lines:
>
>             using (varsession= sessionFactory.OpenStatelessSession
> ())
>             using (var tx =session.BeginTransaction())
>             {
>                 var results =session.CreateCriteria<PaymentDetail>()
>                     // do some filtering
>                     .List<PaymentDetail>();
>
>                 foreach (var paymentDetail in results)
>                 {
>                     paymentDetail.SomeProperty = "123456"
>                    session.Update(paymentDetail);
>                 }
>
>                 tx.Commit();
>             }
>
> In this example, PaymentDetail has a many-to-one to Payment. You can
> see in the stack trace below that the error occurs because it tries to
> initialize the Payment proxy as part of getting the version for
> Payment.
>
> NHibernate.SessionException: proxies cannot be fetched by astatelesssession
> at NHibernate.Impl.StatelessSessionImpl.ImmediateLoad(String
> entityName, Object id)
> at NHibernate.Proxy.AbstractLazyInitializer.Initialize()
> at NHibernate.Proxy.AbstractLazyInitializer.GetImplementation()
> at NHibernate.ByteCode.Castle.LazyInitializer.Intercept(IInvocation
> invocation)
> at Castle.DynamicProxy.AbstractInvocation.Proceed()
> at Castle.Proxies.PaymentProxy.get_Version()
>
> System.Reflection.TargetInvocationException: Exception has been thrown
> by the target of an invocation.
> at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object
> [] arguments, ref SignatureStruct sig, MethodAttributes
> methodAttributes, RuntimeTypeHandle typeOwner)
> at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[]
> arguments, Signature sig, MethodAttributes methodAttributes,
> RuntimeTypeHandle typeOwner)
> at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
> invokeAttr, Binder binder, Object[] parameters, CultureInfo culture,
> Boolean skipVisibilityChecks)
> at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
> invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
> at System.Reflection.RuntimePropertyInfo.GetValue(Object obj,
> BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo
> culture)
> at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[]
> index)
> at NHibernate.Properties.BasicPropertyAccessor.BasicGetter.Get(Object
> target)
>
> NHibernate.PropertyAccessException: Exception occurred getter of
> XXX.Domain.EntityBase.Version
> at NHibernate.Properties.BasicPropertyAccessor.BasicGetter.Get(Object
> target)
> at NHibernate.Tuple.Entity.AbstractEntityTuplizer.GetVersion(Object
> entity)
> at NHibernate.Persister.Entity.AbstractEntityPersister.GetVersion
> (Object obj, EntityMode entityMode)
> at NHibernate.Persister.Entity.AbstractEntityPersister.IsTransient
> (Object entity, ISessionImplementorsession)
> at NHibernate.Engine.ForeignKeys.IsTransient(String entityName, Object
> entity, Nullable`1 assumed, ISessionImplementorsession)
> at NHibernate.Engine.ForeignKeys.GetEntityIdentifierIfNotUnsaved
> (String entityName, Object entity, ISessionImplementorsession)
> at NHibernate.Type.EntityType.GetIdentifier(Object value,
> ISessionImplementorsession)
> at NHibernate.Type.ManyToOneType.NullSafeSet(IDbCommand st, Object
> value, Int32 index, Boolean[] settable, ISessionImplementorsession)
> at NHibernate.Persister.Entity.AbstractEntityPersister.Dehydrate
> (Object id, Object[] fields, Object rowId, Boolean[] includeProperty,
> Boolean[][] includeColumns, Int32 table, IDbCommand statement,
> ISessionImplementorsession, Int32 index)
> at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object
> id, Object[] fields, Object[] oldFields, Object rowId, Boolean[]
> includeProperty, Int32 j, Object oldVersion, Object obj,
> SqlCommandInfo sql, ISessionImplementorsession)
> at NHibernate.Persister.Entity.AbstractEntityPersister.UpdateOrInsert
> (Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean
> [] includeProperty, Int32 j, Object oldVersion, Object obj,
> SqlCommandInfo sql, ISessionImplementorsession)
> at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object
> id, Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection,
> Object[] oldFields, Object oldVersion, Object obj, Object rowId,
> ISessionImplementorsession)
> at NHibernate.Impl.StatelessSessionImpl.Update(String entityName,
> Object entity)
> at NHibernate.Impl.StatelessSessionImpl.Update(Object entity)
>
> Is there anything in particular I need to be aware of when using 
> astatelesssessionwith objects that have optimistic concurrency? The
> only work around I can figure out at this stage is to eager fetch a
> really large chunk of the graph (payment and various other associated
> entities) - but this will be really slow and defeat much of the
> purpose of usingstatelesssession. I actually don't even care about
> the optimistic concurrency for this operation and it would be great if
> I could tell thesession"just ignore the version" but there doesn't
> seem to be a way to do that.
>
> Thanks,
>
> Paul Batum

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

Reply via email to