-->
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.  [ 4 posts ] 
Author Message
 Post subject: How to call MS SQL Server stored procedure with NHibernate?
PostPosted: Tue Mar 13, 2007 1:06 am 
Newbie

Joined: Tue Mar 13, 2007 1:01 am
Posts: 14
I tried times when using NHibernate with MS SQL Server stored procedure but not successful.

Please help me solve this problem.

I want to call stored procedure not only selecting data on 1 table. It can select data on more than 1.

Thanks a lot!


Top
 Profile  
 
 Post subject: what type result of you return?
PostPosted: Tue Mar 13, 2007 3:24 am 
Newbie

Joined: Wed Mar 07, 2007 10:59 pm
Posts: 6
what type result of you return?


Top
 Profile  
 
 Post subject: Hei, this is a org document!
PostPosted: Tue Mar 13, 2007 3:30 am 
Newbie

Joined: Wed Mar 07, 2007 10:59 pm
Posts: 6
13.2.2.1. Rules/limitations for using stored procedures
To use stored procedures with NHibernate the procedures/functions have to follow some rules. If they do not follow those rules they are not usable with NHibernate. If you still want to use these procedures you have to execute them via session.Connection. The rules are different for each database, since database vendors have different stored procedure semantics/syntax.

Stored procedure queries can't be paged with SetFirstResult()/SetMaxResults().

Recommended call form is dependent on your database. For MS SQL Server use exec functionName <parameters>.

For Oracle the following rules apply:

A function must return a result set. The first parameter of a procedure must be an OUT that returns a result set. This is done by using a SYS_REFCURSOR type in Oracle 9 or 10. In Oracle you need to define a REF CURSOR type, see Oracle literature.

For MS SQL server the following rules apply:

The procedure must return a result set. NHibernate will use IDbCommand.ExecuteReader() to obtain the results.

If you can enable SET NOCOUNT ON in your procedure it will probably be more efficient, but this is not a requirement.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 16, 2007 2:21 am 
Newbie

Joined: Tue Mar 13, 2007 1:01 am
Posts: 14
Thanks for your response !

I used NHibernate 1.0.2 so I can not do that.
I know NHibernate 1.2 supports stored procedure so I will update my Nhibernate version.

pcphuc.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.