-->
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.  [ 1 post ] 
Author Message
 Post subject: Problems with CreateSQLQuery using AddEntity / AddJoin....
PostPosted: Wed Aug 17, 2011 8:33 am 
Newbie

Joined: Wed Aug 17, 2011 8:20 am
Posts: 1
Hello,

I am using NHibernate 2.1.2 (needed a .Net 2.0 compliant version). If
I have a query that looks something like:

IQuery iq = querySession.CreateQuery("from RptDocumentBase src where
src.RptDocumentCore in (select srcc.DocCoreId from RptDocumentCore
srcc where contains(srcc.Body, 'florida')>0")

ICollection<RptDocumentBase> col = iq.List<RptDocumentBase>();

... it returns me a nice collection of RptDocumentBase objects. My
problem is that because I had to move back to NHibernate 2.1.2, I no
longer have column lazy loading, so I needed to remove mappings for my
BLOB column (Body). As such, the above query fails because there is
no mapping for src.Body. I could change my query to something like:

IQuery iq = querySession.CreateSQLQuery("select * from rpt_document_base src where src.doc_core_id in (select srcc.doc_core_id from rpt_document_core srcc where contains(srcc.body, 'florida')>0")
ICollection col = iq.List();

This will return a collection of objects, each object being an
object[] of row values. I don't want that though. What I need is to
be able to query against my blob column (my non-mapped "body" field)
and have NHibernate return a collection of RptDocumentBase objects
(like in the first query).

I think I am finding a solution in a different form of the CreateSQLQuery API:

string sql = "select * from rpt_document_base src where src.doc_core_id in (select srcc.doc_core_id from rpt_document_core srcc where contains(srcc.body, 'floride')>0)");
IQuery iq = ses.CreateSQLQuery(sql.ToString())
.AddEntity("src", typeof (RptDocumentBase))
.AddJoin("srcc", "src.RptDocumentCore")
.AddEntity("srcc", typeof (RptDocumentCore));

But this and other variations simply give me the error System.IndexOutOfRabgeException: Unable to find specified column in result set. Seems like that type of query is what I am looking for but I just can't find the right way to use it.

Any thoughts on this?

Thanks - Peter


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.