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: Problems creating queries in nHibernate
PostPosted: Mon Dec 25, 2006 4:49 am 
Newbie

Joined: Mon Nov 20, 2006 3:58 am
Posts: 12
I am developing a system with .NET 2.0 framework and nHibernate and MSSQL 2000. The biggest problem i am facing is in generating complex queries with SQL functions and involving three four tables... so far i am unable to find a tutorial or example describing how to write these queries which have more than couple of tables and some SQL specific terms..

A simple example of such queries is as below
string query = "SELECT DISTINCT category.*" +
" FROM tblItemBO item, tblItemDetailBO itemdetail, tblCountryBO country, tblCategoryBO category" +
" WHERE item.itemDetail_itemDetailBOId = itemdetail.itemDetailBOId" +
" AND itemdetail.itemCategory_categoryId = category.categoryId" +
" AND itemdetail.itemCountry_countryId = country.countryId" +
" AND category.isActive = 1" +
" AND item.auctionClosed = 0" +
" AND country.countryName = '" + myBO.getCountryName() + "'";

Now queries like these keep giving error like "error in FindBySQL"
and .NET throws the following error in browser.
Quote:
categoryId0_
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: categoryId0_


I have searched for quite a few on google but even after 2 days i m clueless.. i m thinking of switching this querty into ICriteria style but i m not finding any good tutorial to help me know how to use multiple tables in the nHibernate

Any help and guidance will be much appreciated


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 26, 2006 1:27 am 
Regular
Regular

Joined: Tue Feb 21, 2006 9:50 am
Posts: 107
A good source for Hibernate queries is the book "Hibernate in Action". It is based on the Java version but most of the concepts described there can be ported to the .NET world. There is a second edition named "Java persistence with Hibernate" out since a few weeks. I would prefer the first edition because the second edition is based on Hibernate 3.0.

Regards
Klaus


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.