The error is "could not update", but the real question is : why UPDATE ?
This is a simple SELECT query, but NH create an UPDATE clause...
Hibernate version:
1.2.0.GA
Mapping documents:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" >
<class name="FinitenessEvo.Domain.OrdineDiLavoro, FinitenessEvo.Domain" table="detcom" >
<composite-id>
<key-property name="CodiceCliente" column="clicod" />
<key-property name="Anno" column="coanno"/>
<key-property name="Numero" column="conume"/>
</composite-id>
<property name="NoteScheda" column="codnot" />
<property name="FlagChiusura" column="codchi" />
<property name="OreTotali" column="codte1" />
<property name="MinutiTotali" column="codte2" />
<property name="OreOriginali" column="codore" />
<property name="MinutiOriginali" column="codmin" />
<property name="Stato" column="codstx" />
<property name="RiferimentoCliente" column="codacl" />
<property name="DataRichiesta" column="codatr" />
<property name="DataConsegnaPrevista" column="codaco" />
<property name="DataComunicazioneCliente" column="codcom" />
<property name="MatricolaAccettante" column="codacc" />
<property name="MatricolaAutorizzazione" column="codaut" />
<property name="TipoIntervento" column="codtip" />
<property name="MatricolaSviluppatore" column="codpgm" />
<property name="DataInizioLavori" column="codinl" />
<property name="SchedaConsegna" column="codcon" />
<property name="TipoTest" column="cotetp" />
<property name="TestIntermedi" column="cotei1" />
<property name="TestFinali" column="cotef1" />
<property name="Testo" column="coddet" />
<many-to-one class="FinitenessEvo.Domain.Commessa, FinitenessEvo.Domain" name="Commessa" not-found="ignore" lazy="proxy" >
<column name="tlicod"/>
<column name="tabann"/>
<column name="tabcom"/>
</many-to-one>
<many-to-one class="FinitenessEvo.Domain.Cliente, FinitenessEvo.Domain" name="Cliente" column="clicod" insert="false" update="false" not-found="ignore" lazy="proxy" />
<many-to-one class="FinitenessEvo.Domain.TipoIntervento, FinitenessEvo.Domain" name="ClsTipoIntervento" column="codtip" insert="false" update="false" not-found="ignore" lazy="proxy" />
<many-to-one class="FinitenessEvo.Domain.Matricola, FinitenessEvo.Domain" name="ClsMatricolaSviluppatore" column="codpgm" insert="false" update="false" not-found="ignore" lazy="proxy" />
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
IQuery queryCommesseODL = this.m_session.CreateQuery("from OrdineDiLavoro as odl where odl.MatricolaSviluppatore=:dev");
queryCommesseODL.SetString("dev", mat.Codice);
foreach (OrdineDiLavoro odl in queryCommesseODL.List<OrdineDiLavoro>())
{}
Full stack trace of any exception that occurs:Code:
in NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session)
in NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object obj, ISessionImplementor session)
in NHibernate.Impl.ScheduledUpdate.Execute()
in NHibernate.Impl.SessionImpl.Execute(IExecutable executable)
in NHibernate.Impl.SessionImpl.ExecuteAll(IList list)
in NHibernate.Impl.SessionImpl.Execute()
in NHibernate.Impl.SessionImpl.AutoFlushIfRequired(ISet querySpaces)
in NHibernate.Impl.SessionImpl.GetQueries(String query, Boolean scalar)
in NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters, IList results)
in NHibernate.Impl.SessionImpl.Find[T](String query, QueryParameters parameters)
in NHibernate.Impl.QueryImpl.List[T]()
in FinitenessEvo.GUI.frmShowGantt.RefreshUsers() in C:\Documents and Settings\luke\Desktop\FinitenessEvo\Finiteness Evo\frmShowGantt.cs:riga 326
in FinitenessEvo.GUI.frmShowGantt.frmShowGantt_Load(Object sender, EventArgs e) in C:\Documents and Settings\luke\Desktop\FinitenessEvo\Finiteness Evo\frmShowGantt.cs:riga 39
in System.Windows.Forms.Form.OnLoad(EventArgs e)
in System.Windows.Forms.Form.OnCreateControl()
in System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
in System.Windows.Forms.Control.CreateControl()
in System.Windows.Forms.Control.WmShowWindow(Message& m)
in System.Windows.Forms.Control.WndProc(Message& m)
in System.Windows.Forms.ScrollableControl.WndProc(Message& m)
in System.Windows.Forms.ContainerControl.WndProc(Message& m)
in System.Windows.Forms.Form.WmShowWindow(Message& m)
in System.Windows.Forms.Form.WndProc(Message& m)
in System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
in System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
in System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
in System.Windows.Forms.UnsafeNativeMethods.IntCreateWindowEx(Int32 dwExStyle, String lpszClassName, String lpszWindowName, Int32 style, Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent, HandleRef hMenu, HandleRef hInst, Object pvParam)
in System.Windows.Forms.UnsafeNativeMethods.CreateWindowEx(Int32 dwExStyle, String lpszClassName, String lpszWindowName, Int32 style, Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent, HandleRef hMenu, HandleRef hInst, Object pvParam)
in System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
in System.Windows.Forms.Control.CreateHandle()
in System.Windows.Forms.Form.CreateHandle()
in System.Windows.Forms.Control.get_Handle()
in System.Windows.Forms.Form.SetVisibleCore(Boolean value)
in System.Windows.Forms.Control.Show()
in FinitenessEvo.GUI.frmHome.menuProgrammazioneGantt_Click(Object sender, EventArgs e) in C:\Documents and Settings\luke\Desktop\FinitenessEvo\Finiteness Evo\frmHome.cs:riga 56
in FinitenessEvo.GUI.frmHome.toocmdGantt_Click(Object sender, EventArgs e) in C:\Documents and Settings\luke\Desktop\FinitenessEvo\Finiteness Evo\frmHome.cs:riga 93
in System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
in System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
in System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
in System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
in System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
in System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
in System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
in System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
in System.Windows.Forms.Control.WndProc(Message& m)
in System.Windows.Forms.ScrollableControl.WndProc(Message& m)
in System.Windows.Forms.ToolStrip.WndProc(Message& m)
in System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
in System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
in System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
in System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
in System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
in System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
in System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
in System.Windows.Forms.Application.Run(Form mainForm)
in FinitenessEvo.GUI.Program.Main() in C:\Documents and Settings\luke\Desktop\FinitenessEvo\Finiteness Evo\Program.cs:riga 32
in System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
in System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
in System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
in System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
in System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
in Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
in System.Threading.ThreadHelper.ThreadStart_Context(Object state)
in System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
in System.Threading.ThreadHelper.ThreadStart()
Name and version of the database you are using:Microsoft SQL Server 2005
The generated SQL (show_sql=true):Code:
{UPDATE detcom SET codnot = ?, codchi = ?, codte1 = ?, codte2 = ?, codore = ?, codmin = ?, codstx = ?, codacl = ?, codatr = ?, codaco = ?, codcom = ?, codacc = ?, codaut = ?, codtip = ?, codpgm = ?, codinl = ?, codcon = ?, cotetp = ?, cotei1 = ?, cotef1 = ?, coddet = ?, tlicod = ?, tabann = ?, tabcom = ? WHERE clicod = ? AND coanno = ? AND conume = ?}