gerade erstellt wurde So beschäftige ich mich mit dem Fehler:StaleObjectStateException ich bin immer ein Benutzerkonto auf Update, die
Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [Domain.Entities.General.Shipping#0]
, wenn der Benutzer will, um ihre Lieferadresse in meiner Anwendung aktualisieren.
-Controller
var shippingToAdd = new Shipping
{
UserId = newUserId,
FirstName = model.FirstName,
LastName = model.LastName,
Address = model.ShippingStreet,
SteApt = model.ShippingAptSte,
City = model.ShippingCity,
State = model.ShippingState,
Zip = model.ShippingZip,
Country = shippingCountryId,
};
UserManagerService.UpdateShipping(shippingToAdd);
UserManagerService
public static ISession Context { get; set; }
public UserManagerService(ISession context)
{
Context = context;
}
public static int UpdateShipping(Shipping shipping)
{
using (ITransaction transaction = Context.BeginTransaction())
{
Context.Update(shipping);
transaction.Commit();
return 0; //Right Here is where StaleObjectStateException occurs
}
}
Gibt es trotzdem, um die Sperre zu heben, kurz bevor der Commit()? Oder was ist der beste Weg, um eine Sperre im Allgemeinen zu lösen?
STACK TRACE
[StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [Domain.Entities.General.Shipping#0]]
NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session) +2548
NHibernate.Persister.Entity.AbstractEntityPersister.UpdateOrInsert(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session) +533
NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object obj, Object rowId, ISessionImplementor session) +2372
NHibernate.Action.EntityUpdateAction.Execute() +975
NHibernate.Engine.ActionQueue.Execute(IExecutable executable) +63
NHibernate.Engine.ActionQueue.ExecuteActions(IList list) +165
NHibernate.Engine.ActionQueue.ExecuteActions() +68
NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session) +451
NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event)+286 NHibernate.Impl.SessionImpl.Flush() +385 Service.Account.UserManagerService.UpdateShipping(Shipping shipping) in c:\Users\wd\Desktop\master\Service\Account\UserManagerService.cs:189
Controllers.PayPalController.PaymentWithCreditCard(CartViewModel model, IEnumerable1 cookiecart) in c:\Users\wd\Desktop\master\Controllers\PayPalController.cs:552
2 parameters) +603
Controllers.PayPalController.Continue(CartViewModel model) in c:\Users\wd\Desktop\master\Controllers\PayPalController.cs:136
lambda_method(Closure , ControllerBase , Object[]) +268
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +87
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +93
2.CallEndDelegate(IAsyncResult asyncResult) +137
System.Web.Mvc.Async.ActionInvocation.InvokeSynchronousActionMethod() +97 System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +53
System.Web.Mvc.Async.WrappedAsyncResult
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +187
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +136
Sie haben hier nicht genügend Informationen zur Verfügung gestellt. Zum Beispiel, was ist 'Context.Update (...)'? – DavidG
Entschuldigung hinzugefügt es in meinem Update. – NeoSketo
Immer noch nicht genug Infos, ist das vielleicht nHibernate? Wir sind nicht psychisch! – DavidG