-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: HQL inner join
PostPosted: Sat Mar 17, 2007 9:04 pm 
Regular
Regular

Joined: Thu May 11, 2006 12:30 pm
Posts: 72
I need to do an inner join between 2 entity but I'm getting always this error

"Could not execute query"
{"Il valore \"System.Object[]\" non è di tipo \"FinitenessEvo.Domain.OrdineDiLavoro\" e non può essere utilizzato in questo insieme generico.\r\nNome parametro: value"}

Hibernate version:
1.2.0.3001

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" insert="false" update="false" not-found="ignore" fetch="join" >
      <column name="tlicod"/>
      <column name="tabann"/>
      <column name="tabcom"/>
    </many-to-one>
  </class>
</hibernate-mapping>


Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" >
  <class name="FinitenessEvo.Domain.Commessa, FinitenessEvo.Domain" table="tabcom" >
    <composite-id>
      <key-property name="CodiceCliente" column="tlicod" />
      <key-property name="Anno" column="tabann"/>
      <key-property name="Nome" column="tabcom"/>
    </composite-id>
    <property name="Descrizione" column="tabdes" />
    <property name="Stato" column="tabchi" />
  </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Code:
IQuery queryCommesseODL = this.m_session.CreateQuery("from OrdineDiLavoro as odl inner join odl.Commessa");
                foreach (OrdineDiLavoro odl in queryCommesseODL.List<OrdineDiLavoro>())


Full stack trace of any exception that occurs:
Code:
   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\Finiteness Evo\Finiteness Evo\frmShowGantt.cs:riga 184
   in FinitenessEvo.GUI.frmShowGantt.frmShowGantt_Load(Object sender, EventArgs e) in C:\Documents and Settings\luke\Desktop\Finiteness Evo\Finiteness Evo\frmShowGantt.cs:riga 39
   in System.Windows.Forms.Form.OnLoad(EventArgs e)
   in ComponentFactory.Krypton.Toolkit.KryptonForm.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 ComponentFactory.Krypton.Toolkit.VisualForm.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\Finiteness Evo\Finiteness Evo\frmHome.cs:riga 52
   in FinitenessEvo.GUI.frmHome.toocmdGantt_Click(Object sender, EventArgs e) in C:\Documents and Settings\luke\Desktop\Finiteness Evo\Finiteness Evo\frmHome.cs:riga 68
   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\Finiteness Evo\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:
MS SQL Server 2005
The generated SQL (show_sql=true):


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 18, 2007 7:19 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
The query should be "select odl from OrdineDiLavoro as odl inner join odl.Commessa", otherwise NHibernate thinks you want it to return both odl and odl.Commessa.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 19, 2007 5:01 am 
Regular
Regular

Joined: Thu May 11, 2006 12:30 pm
Posts: 72
I tried it but if I add select odl NHbernate raise ana exception updating (!?) OrdineDiLavoro...why it do an UPDATE ??

Exception :

Code:
{"could not update: [FinitenessEvo.Domain.OrdineDiLavoro#FinitenessEvo.Domain.OrdineDiLavoro][SQL: UPDATE detcom SET codnot = ?, codchi = ?, codte1 = ?, codte2 = ?, codore = ?, codmin = ?, codstx = ?, codacl = ?, codatr = ?, codaco = ?, codcom = ?, codacc = ?, codaut = ?, codtip = ?, codpgm = ?, codinl = ?, codcon = ?, cotetp = ?, cotei1 = ?, cotef1 = ?, coddet = ? WHERE clicod = ? AND coanno = ? AND conume = ?]"}


Inner exception :

Code:
{"Overflow di SqlDateTime. Deve essere compreso tra 1/1/1753 12:00:00 AM e 12/31/9999 11:59:59 PM."}


Stack trace :

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\Finiteness Evo\Finiteness Evo\frmShowGantt.cs:riga 184
   in FinitenessEvo.GUI.frmShowGantt.frmShowGantt_Load(Object sender, EventArgs e) in C:\Documents and Settings\luke\Desktop\Finiteness Evo\Finiteness Evo\frmShowGantt.cs:riga 39
   in System.Windows.Forms.Form.OnLoad(EventArgs e)
   in ComponentFactory.Krypton.Toolkit.KryptonForm.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 ComponentFactory.Krypton.Toolkit.VisualForm.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\Finiteness Evo\Finiteness Evo\frmHome.cs:riga 52
   in FinitenessEvo.GUI.frmHome.toocmdGantt_Click(Object sender, EventArgs e) in C:\Documents and Settings\luke\Desktop\Finiteness Evo\Finiteness Evo\frmHome.cs:riga 68
   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\Finiteness Evo\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()


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 19, 2007 5:38 am 
Regular
Regular

Joined: Thu May 11, 2006 12:30 pm
Posts: 72
found !

I need to specify an alias even for odl.Commessa elsewhere I gave that exception


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.