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
|