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.  [ 7 posts ] 
Author Message
 Post subject: Could not find specified column in results
PostPosted: Tue Jul 03, 2007 12:44 am 
Newbie

Joined: Mon Mar 26, 2007 7:50 am
Posts: 18
Hi all,
I need a little help with NHibernat,
I try to execute a storedProcedure from my App. but get the following Error:
Code:
"could not execute query\r\n[ Call sample() ]\r\n[SQL: Call sample()]"
{"Could not find specified column in results"}

that's how my procedure is looking like:
Code:
DELIMITER $$

DROP PROCEDURE IF EXISTS `nhibernate`.`sample` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `sample`()
BEGIN
  SELECT * FROM `users`;
END $$

DELIMITER ;


What am I doing wrong???

regards,
Omid

Hibernate version:
NHibernate 1.2.0
Mapping documents:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernateSample"
    namespace="NHibernateSample">
    <class name="User" table="users" lazy="true">
        <id name="Id" column="LogonId" type="String" length="20">
            <generator class="assigned" />
        </id>
        <property name="UserName" column="Name" type="String" length="40"/>
        <property name="Password" type="String" length="20"/>
        <property name="EmailAddress" type="String" length="40"/>
        <property name="LastLogon" type="DateTime"/>
    </class>

  <sql-query name="Sample_SP">
    <return alias="usr" class="User">
      <return-property name="LogonId" column="LogonId"/>
      <return-property name="UserName" column="UserName"/>
      <return-property name="Password" column="Password"/>
      <return-property name="EmailAddress" column="EmailAddress"/>
      <return-property name="LastLogon" column="LastLogon"/>
    </return>
    Call sample()
  </sql-query>
 
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Code:
ISessionFactory factory = cfg.BuildSessionFactory();
            ISession session = factory.OpenSession();

            IList list = session.GetNamedQuery("Sample_SP").List();

            session.Close();

Full stack trace of any exception that occurs:
Code:
"   at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
   at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters)
   at NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet querySpaces, IType[] resultTypes)
   at NHibernate.Loader.Custom.CustomLoader.List(ISessionImplementor session, QueryParameters queryParameters)
   at NHibernate.Impl.SessionImpl.ListCustomQuery(ICustomQuery customQuery, QueryParameters queryParameters, IList results)
  at NHibernate.Impl.SessionImpl.List(NativeSQLQuerySpecification spec, QueryParameters queryParameters, IList results)
   at NHibernate.Impl.SessionImpl.List(NativeSQLQuerySpecification spec, QueryParameters queryParameters)
   at NHibernate.Impl.SqlQueryImpl.List()
   at NHibernateSample.Form1.button3_Click(Object sender, EventArgs e) in C:\\Dokumente und Einstellungen\\Administrator\\Eigene Dateien\\Visual Studio 2005\\Projects\\NHibernateSample\\NHibernateSample\\Form1.cs:line 62
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
  at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at NHibernateSample.Program.Main() in C:\\Dokumente und Einstellungen\\Administrator\\Eigene Dateien\\Visual Studio 2005\\Projects\\NHibernateSample\\NHibernateSample\\Program.cs:line 17
   at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)\r\n   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
  at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()"

Name and version of the database you are using:
Code:
Mysql


Top
 Profile  
 
 Post subject: missing info
PostPosted: Tue Jul 03, 2007 5:06 pm 
Newbie

Joined: Tue Jul 03, 2007 2:06 pm
Posts: 14
Location: Turkey, Ankara
could you please give the hibernate mapping file and the class for user also. The problem is not here i think.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 04, 2007 3:16 am 
Newbie

Joined: Thu May 03, 2007 7:24 am
Posts: 6
I noticed you had the property name as LogonId in your procedure mapping even though the property name in your mapping for the User class is called 'Id'.

Curious if that is the cause the error you are seeing. Wanna try adjusting that?

Cheers,

_________________
Naraendirakumar R.R.


Top
 Profile  
 
 Post subject: Re: missing info
PostPosted: Wed Jul 04, 2007 3:55 am 
Newbie

Joined: Mon Mar 26, 2007 7:50 am
Posts: 18
hcfk wrote:
could you please give the hibernate mapping file and the class for user also. The problem is not here i think.


Hi and thank you for the response.
The mapping file is posted in the first post but here again:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernateSample"
    namespace="NHibernateSample">
    <class name="User" table="users" lazy="true">
        <id name="Id" column="LogonId" type="String" length="20">
            <generator class="assigned" />
        </id>
        <property name="UserName" column="Name" type="String" length="40"/>
        <property name="Password" type="String" length="20"/>
        <property name="EmailAddress" type="String" length="40"/>
        <property name="LastLogon" type="DateTime"/>
    </class>

  <sql-query name="Sample_SP">
    <return alias="usr" class="User">
      <return-property name="Id" column="LogonId"/>
      <return-property name="Name" column="UserName"/>
      <return-property name="Pword" column="Password"/>
      <return-property name="EAddress" column="EmailAddress"/>
      <return-property name="LLogon" column="LastLogon"/>
    </return>
    call sample()
  </sql-query>
 
</hibernate-mapping>


and here the User Class:
Code:
using System;
using System.Collections.Generic;
using System.Text;

namespace NHibernateSample
{
    public class User
    {
        private string id;
        private string userName;
        private string password;
        private string emailAddress;
        private DateTime lastLogon;


        public User()
        {
        }

        public virtual string Id
        {
            get { return id; }
            set { id = value; }
        }

        public virtual string UserName
        {
            get { return userName; }
            set { userName = value; }
        }

        public virtual string Password
        {
            get { return password; }
            set { password = value; }
        }

        public virtual string EmailAddress
        {
            get { return emailAddress; }
            set { emailAddress = value; }
        }

        public virtual DateTime LastLogon
        {
            get { return lastLogon; }
            set { lastLogon = value; }
        }
       
    }
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 04, 2007 3:57 am 
Newbie

Joined: Mon Mar 26, 2007 7:50 am
Posts: 18
Naraen wrote:
I noticed you had the property name as LogonId in your procedure mapping even though the property name in your mapping for the User class is called 'Id'.

Curious if that is the cause the error you are seeing. Wanna try adjusting that?

Cheers,


Hi,
thanks for your response, I tried it, but it seems not to be the reason ;)

regards,
Omid


Top
 Profile  
 
 Post subject: Naming problem
PostPosted: Thu Jul 05, 2007 3:10 pm 
Newbie

Joined: Tue Jul 03, 2007 2:06 pm
Posts: 14
Location: Turkey, Ankara
In the mapping file u declared column="Name" but in the sql u query for column="UserName" i think this is the problem.

_________________
it is what they understand from your sayings, not what u know.

Fatih Kucukpetek


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 05, 2007 11:52 pm 
Newbie

Joined: Mon Mar 26, 2007 7:50 am
Posts: 18
Thank you hcfk,

it was the problem....


regards,
Omid


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.