-->
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.  [ 2 posts ] 
Author Message
 Post subject: Return types of SQL query were not specified
PostPosted: Mon Aug 13, 2007 8:04 am 
Newbie

Joined: Mon Aug 06, 2007 10:43 am
Posts: 2
HI.

I'm a begginer using nhibernate.

Basically i'm changing an old project to use nhibernate, to study and test purposes.

I'm getting the exception subject of this post.

Thank you for any help.

Alexandre

Hibernate version:
1.2.0.4000

Mapping documents:

Code between sessionFactory.openSession() and session.close():

ISession session = _factory.OpenSession();
ISQLQuery query = session.CreateSQLQuery("SELECT DISTINCT TNSECAO.CODSECAO, TNSECAO.DESCRSECAO FROM TNSECLINHA INNER JOIN TNSECAO ON TNSECLINHA.CODSECAODESTINO = TNSECAO.CODSECAO WHERE (TNSECLINHA.CODSECAOORIGEM = " + CodOrigem + ") ORDER BY DESCRSECAO");
List<Tnsecao> listaObjetos = ConvertIListToGenericList(query.List());
session.Close();
return listaObjetos;

Full stack trace of any exception that occurs:

" em NHibernate.Impl.SqlQueryImpl.VerifyParameters()\r\n em NHibernate.Impl.SqlQueryImpl.List()\r\n em DAL.Tnsecao.ListDestinos(Decimal CodOrigem) na C:\\Users\\Alexandre\\Desktop\\Gerador\\Passagemweb\\Tnsecao.cs:linha 194\r\n em Transnorte.ucSelecaoViagem.ddlOrigem_SelectedIndexChanged(Object sender, EventArgs e) na C:\\Users\\Alexandre\\Documents\\Visual Studio 2005\\Projects\\Transnorte\\Transnorte\\ucSelecaoViagem.ascx.vb:linha 32\r\n em System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e)\r\n em System.Web.UI.WebControls.DropDownList.RaisePostDataChangedEvent()\r\n em System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent()\r\n em System.Web.UI.Page.RaiseChangedEvents()\r\n em System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)"

Name and version of the database you are using:

MS Sql Server 2005 Express

The generated SQL (show_sql=true):

"SELECT DISTINCT TNSECAO.CODSECAO, TNSECAO.DESCRSECAO FROM TNSECLINHA INNER JOIN TNSECAO ON TNSECLINHA.CODSECAODESTINO = TNSECAO.CODSECAO WHERE (TNSECLINHA.CODSECAOORIGEM = 23) ORDER BY DESCRSECAO"

Debug level Hibernate log excerpt:

{"Return types of SQL query were not specified [SELECT DISTINCT TNSECAO.CODSECAO, TNSECAO.DESCRSECAO FROM TNSECLINHA INNER JOIN TNSECAO ON TNSECLINHA.CODSECAODESTINO = TNSECAO.CODSECAO WHERE (TNSECLINHA.CODSECAOORIGEM = 23) ORDER BY DESCRSECAO]"}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 15, 2007 9:36 am 
Newbie

Joined: Mon Aug 06, 2007 10:43 am
Posts: 2
I found the solution.

Here goes if anyone came across the same problem.

Changed the code to between open() and close() session as below:

Code:
            ISession session = _factory.OpenSession();
            String sql = "SELECT DISTINCT TNSECAO.* " +
                    "FROM TNSECLINHA INNER JOIN TNSECAO ON " +
                    "TNSECLINHA.CODSECAODESTINO = TNSECAO.CODSECAO " +
                    "WHERE (TNSECLINHA.CODSECAOORIGEM = " + CodOrigem + ") ORDER BY DESCRSECAO";

            IQuery query = session.CreateSQLQuery(sql).AddEntity(typeof(Tnsecao));
            List<Tnsecao> listaObjetos = ConvertIListToGenericList(query.List());
            session.Close();
            return listaObjetos;


The documentation about this is not so clear (maybe to me, on the first reading). And i have not found much code hints on the Internet.


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