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.  [ 3 posts ] 
Author Message
 Post subject: Newbie problem with Query
PostPosted: Wed Aug 30, 2006 1:15 pm 
Newbie

Joined: Wed Aug 30, 2006 1:03 pm
Posts: 1
I´m trying to make a simple SELECT statement...but I don´t know what´s going on...

Hibernate version: 1.2 alpha

Mapping documents: <?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" namespace="Banco" assembly="Banco">
<class name="Tbcliente" table="TBCLIENTE" lazy="false">

<id name="Id" column="ID" type="Int32" unsaved-value="0">
<generator class="assigned"/>
</id>
<property column="COD_CLIENTE" type="Int32" name="m_COD_CLIENTE" not-null="true" />
<property column="NOM_CLIENTE" type="String" name="m_NOM_CLIENTE" length="100" />
<property column="COD_CONV" type="Int32" name="m_COD_CONV" />

</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close(): public static IList RetornaClientes(string column, int maximumRows, int startRowIndex)
{
IList result = null;
ISession session = NHibernateHelper.GetCurrentSession();
ITransaction tx = session.BeginTransaction();
string sql = " FROM TBCLIENTE CLIENTE";
if (!String.IsNullOrEmpty(column))
{
sql += " ORDER BY CLIENTE." + column;
}
IQuery query = session.CreateQuery(sql);
query.SetFirstResult(startRowIndex);
query.SetMaxResults(maximumRows);
result = query.List();
tx.Commit();
return result;
}


Full stack trace of any exception that occurs: [QueryException: in expected: CLIENTE [ FROM TBCLIENTE CLIENTE]]
NHibernate.Hql.FromParser.Token(String token, QueryTranslator q) +1488
NHibernate.Hql.ClauseParser.Token(String token, QueryTranslator q) +930
NHibernate.Hql.PreprocessingParser.End(QueryTranslator q) +43
NHibernate.Hql.ParserHelper.Parse(IParser p, String text, String seperators, QueryTranslator q) +267
NHibernate.Hql.QueryTranslator.Compile() +156
NHibernate.Hql.QueryTranslator.Compile(IDictionary replacements, Boolean scalar) +67
NHibernate.Impl.SessionFactoryImpl.GetQuery(String queryString, Boolean shallow) +219
NHibernate.Impl.SessionImpl.GetQueries(String query, Boolean scalar) +58
NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters, IList results) +156
NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters) +59
NHibernate.Impl.QueryImpl.List() +90
AtividadeDAO.RetornaClientes(String column, Int32 maximumRows, Int32 startRowIndex) in c:\nhibernate\pj_nhibernate\App_Code\AtividadeDAO.cs:39

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +0
System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +72
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +358
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +29
System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +17
System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance) +676
System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +2661
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +84
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +154
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +99
System.Web.UI.WebControls.GridView.DataBind() +24
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +91
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +101
System.Web.UI.Control.EnsureChildControls() +134
System.Web.UI.Control.PreRenderRecursiveInternal() +109
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4435


Name and version of the database you are using: Firebird 1.5


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 30, 2006 8:46 pm 
Newbie

Joined: Wed Aug 16, 2006 2:49 am
Posts: 14
string sql = " FROM TBCLIENTE CLIENTE";

This is just a hard guess. Maybe the space in the beginning of your queryString causes the problem. Not sure though. Try making it 'string sql = "FROM TBCLIENTE CLIENTE";' instead


Top
 Profile  
 
 Post subject: Re: Newbie problem with Query
PostPosted: Fri Sep 01, 2006 8:04 am 
Beginner
Beginner

Joined: Wed Aug 03, 2005 8:06 am
Posts: 40
Location: Netherlands
Hi,

Just always use the class name in HQL, so Tbcliente not TBCLIENTE.


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