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: ADOException "could not execute query" on valid SQ
PostPosted: Fri Jan 26, 2007 4:13 pm 
Newbie

Joined: Fri Jan 26, 2007 2:21 pm
Posts: 1
I've spent some time trying to figure out where this is going wrong, and I'm thinking it's going to be something ridiculously simple. Thanks for any help or advice here!

I keep getting an ADOException saying "could not execute query", but when examining the generated SQL it's perfectly valid. If I take it and put it in the SQLServer management tool it validates and runs with the expected result. Queries on other tables from nHibernate work as well, so I'm at a loss on what to investigate next.

Hibernate version: 1.2.0.2001

Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"
schema="dbo"
assembly="bbgLib"
namespace="bbgLib"
>
<class
name="bbgLib.RandomItem"
table="npc_drops"
lazy="false"
>
<id
name="ItemId"
type="Int32"
column="npcDropId"
unsaved-value="0"
access="property">
<generator class="identity" />
</id>
<property
name="NpcId"
column="npcId"
/>
<property
name="BaseItem"
column="baseItem"
/>
<property
name="BaseType"
column="baseType"
/>
<property
name="DropChance"
column="dropChance"
/>
<property
name="AllowedPre"
column="allowedPre"
/>
<property
name="AllowedPost"
column="allowedPost"
/>
<property
name="AllowedHidden"
column="allowedHidden"
/>
</class>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Code:
            NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
            cfg.AddAssembly("bbgLib.sqlProvider");
            factory = cfg.BuildSessionFactory();
----
            NHibernate.IQuery query = factory.OpenSession().CreateQuery("FROM RandomItem WHERE NpcId = :NpcId");
            query.SetString("NpcId", NpcId.ToString());
            return query.List<RandomItem>();


Full stack trace of any exception that occurs:
[ADOException: could not execute query[SQL: select randomitem0_.npcDropId as npcDropId4_, randomitem0_.npcId as npcId4_, randomitem0_.baseItem as baseItem4_, randomitem0_.baseType as baseType4_, randomitem0_.dropChance as dropChance4_, randomitem0_.allowedPre as allowedPre4_, randomitem0_.allowedPost as allowedP7_4_, randomitem0_.allowedHidden as allowedH8_4_ from dbo.npc_drops randomitem0_ where (NpcId=2)]]
NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) in c:\net\nhibernate-1.2.0.Beta1\nhibernate\src\NHibernate\Loader\Loader.cs:1656
NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters) in c:\net\nhibernate-1.2.0.Beta1\nhibernate\src\NHibernate\Loader\Loader.cs:1600
NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet querySpaces, IType[] resultTypes) in c:\net\nhibernate-1.2.0.Beta1\nhibernate\src\NHibernate\Loader\Loader.cs:1594
NHibernate.Hql.QueryTranslator.List(ISessionImplementor session, QueryParameters queryParameters) in c:\net\nhibernate-1.2.0.Beta1\nhibernate\src\NHibernate\Hql\QueryTranslator.cs:997
NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters, IList results) in c:\net\nhibernate-1.2.0.Beta1\nhibernate\src\NHibernate\Impl\SessionImpl.cs:1808
NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters) in c:\net\nhibernate-1.2.0.Beta1\nhibernate\src\NHibernate\Impl\SessionImpl.cs:1776
NHibernate.Impl.QueryImpl.List() in c:\net\nhibernate-1.2.0.Beta1\nhibernate\src\NHibernate\Impl\QueryImpl.cs:88
bbgLib.sqlProvider.sqlDataProvider.GetPossibleItemsByNPC(Int32 NpcId) in C:\...\bbgLib.sqlProvider\sqlDataProvider.cs:207
bbgLib.EncounterCombat.NpcDies(Character pc) in C:\...\bbgLib\EncounterCombat.cs:115
bbgLib.EncounterCombat.MeleeAttack(Character pc) in C:\...\bbgLib\EncounterCombat.cs:88
bbgLib.EncounterCombat.ResolveRound(Character pc, ATTACK_TYPE at, String spell) in C:\...\bbgLib\EncounterCombat.cs:51
Controls_EncounterManager.DoCombat(ATTACK_TYPE currentAtkType) in c:\...\BBG\Controls\EncounterManager.ascx.cs:169
Controls_EncounterManager.attack_Click(Object sender, EventArgs e) in c:\...\BBG\Controls\EncounterManager.ascx.cs:142
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +96
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +116
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +72
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3840

Name and version of the database you are using: SQL Server 9.00.2047.00

The generated SQL (show_sql=true):
select randomitem0_.npcDropId as npcDropId4_, randomitem0_.npcId as npcId4_, randomitem0_.baseItem as baseItem4_, randomitem0_.baseType as baseType4_, randomitem0_.dropChance as dropChance4_, randomitem0_.allowedPre as allowedPre4_, randomitem0_.allowedPost as allowedP7_4_, randomitem0_.allowedHidden as allowedH8_4_ from dbo.npc_drops randomitem0_ where (NpcId=2)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 26, 2007 5:26 pm 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
This is no the full exception stack, what is the inner exception?


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.