support nhibernate named queries

Posts   
 
    
costab
User
Posts: 36
Joined: 21-Aug-2010
# Posted on: 20-Apr-2011 09:32:49   

Is there any support for nhibernate named queries?

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 20-Apr-2011 09:41:08   

Do you mean pre-canned SQL queries in the Designer? Not supported too.

Form your last questions it seems that you want to write SQL code by hand, either with SPs or in the Designe, correct?

Why would you do that and use ORM tool at the same time. The idea behind an ORM tool is that it automates the SQL code writing so you don't have to write them, and the most importantly won't have to manitain them when your model changes.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 20-Apr-2011 09:55:32   

You can add the named queries to the hbm files or fluentnh files if you want to. We added regions to the code for that so they don't get overwritten when you re-generate. For fluentNH we added a partial method call so you can add the named queries in a partial class of the mapping class.

does that answer your question?

Frans Bouma | Lead developer LLBLGen Pro
costab
User
Posts: 36
Joined: 21-Aug-2010
# Posted on: 20-Apr-2011 23:43:48   

Yes, it does.

Thank you

costab
User
Posts: 36
Joined: 21-Aug-2010
# Posted on: 20-Apr-2011 23:51:36   

Walaa wrote:

Form your last questions it seems that you want to write SQL code by hand, either with SPs or in the Designe, correct? Why would you do that and use ORM tool at the same time.

Yes, that is correct.

From my point of view they are not mutually exclusive, the two techniques are complementary. I am going to use the ORM tool most of the time but there might be cases - for instance to retrieve recursive data - where I need to use stored procedures. I wish your tool allowed me to configure these procedures and then it would have generated some class that has all the methods that called the stored procedures. The idea is similar with linq-to-sql models where you can add procedures as well and they become methods of the data context. The other thing the tool would have been good at was to define a class that mapped to the record of the resultset returned by my stored procedure (so I don't have to do it manually), or it could allow me to map an existing class to the resultset returned.