-->
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: CreateSQLQuery working in NHibernate 0.8.4.0 ?
PostPosted: Sun Jul 03, 2005 12:37 pm 
Newbie

Joined: Sun Jul 03, 2005 3:54 am
Posts: 9
Hi

Does CreateSQLQuery work in version 0.8.4? Or do I have to get a version from cvs?
I have the following code on 0.8.4 (not form cvs)

Code:
string sql = "SELECT {t2.Id}, {t2.PageName}, {t2.Allow} FROM (Roles {t1} " +
"INNER JOIN Pages {t2} ON t2.RoleId = t1.RoleId) " +
"INNER JOIN Users {t3} ON t3.RoleId = t1.RoleId " +
"WHERE {t3}.UserId = :UserId";
IQuery q = this._activeSession.CreateSQLQuery(sql, new string[] { "t2", "t3", "t1" },
new System.Type[] { typeof( PagesEntity ), typeof( UsersEntity ), typeof( RolesEntity ) });
q.SetInt32("UserId", 11);
IList results = q.List();


When it gets executed, I get the following exception in NHibernate\Type\NullableType.cs Line: 210:

Quote:
IndexOutOfRangeException: PageId0_
System.Data.Common.FieldNameLookup.GetOrdinal(String fieldName)
System.Data.OleDb.OleDbDataReader.GetOrdinal(String name)
NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name) in D:\Support\SupportWebSite\SupportWebSite\src\NHibernate\Type\NullableType.cs:210
NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String[] names, ISessionImplementor session, Object owner) in D:\Support\SupportWebSite\SupportWebSite\src\NHibernate\Type\NullableType.cs:169
NHibernate.Loader.Loader.GetKeyFromResultSet(Int32 i, ILoadable persister, Object id, IDataReader rs, ISessionImplementor session) in D:\Support\SupportWebSite\SupportWebSite\src\NHibernate\Loader\Loader.cs:505
NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, IList hydratedObjects, Object optionalObject, Object optionalId, Key[] keys, Boolean returnProxies) in D:\Support\SupportWebSite\SupportWebSite\src\NHibernate\Loader\Loader.cs:242
NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies) in D:\Support\SupportWebSite\SupportWebSite\src\NHibernate\Loader\Loader.cs:328
NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies) in D:\Support\SupportWebSite\SupportWebSite\src\NHibernate\Loader\Loader.cs:180
NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) in D:\Support\SupportWebSite\SupportWebSite\src\NHibernate\Loader\Loader.cs:155
NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet querySpaces, IType[] resultTypes) in D:\Support\SupportWebSite\SupportWebSite\src\NHibernate\Loader\Loader.cs:1115
NHibernate.Loader.SqlLoader.List(ISessionImplementor session, QueryParameters queryParameters) in D:\Support\SupportWebSite\SupportWebSite\src\NHibernate\Loader\SqlLoader.cs:225
NHibernate.Impl.SessionImpl.FindBySQL(String sqlQuery, String[] aliases, Type[] classes, QueryParameters queryParameters, ICollection querySpaces) in D:\Support\SupportWebSite\SupportWebSite\src\NHibernate\Impl\SessionImpl.cs:5248
NHibernate.Impl.SqlQueryImpl.List() in D:\Support\SupportWebSite\SupportWebSite\src\NHibernate\Impl\SqlQueryImpl.cs:80
Si.Support.Data.HibernateUtils.GetUserByUsernameAndPassword(String username, String password) in d:\support\supportwebsite\supportwebsite\src\server\si.support.data\hibernateutils.cs:289
SupportWebSite.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\supportwebsite\default.aspx.cs:60
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()


Lp
Sebastijan


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 04, 2005 4:11 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Yes, you should get a cvs version, in 0.8.4 SQL query support wasn't finished and had some serious bugs.


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.