-->
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: can call storedprocedure through NHibernate 0.9.1.0 ?
PostPosted: Fri Sep 09, 2005 4:47 am 
can call storedprocedure through NHibernate 0.9.1.0 ?

Hibernate 3 or 3.1 can call storedprocdure.
NHibernate can it ?

(I use SQLServer2000.)


Top
  
 
 Post subject:
PostPosted: Fri Sep 09, 2005 7:46 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
NHibernate is based on Hibernate 2.1 and so does not support stored procedures.


Top
 Profile  
 
 Post subject: does not support...regret!
PostPosted: Fri Sep 09, 2005 12:35 pm 
[quote="sergey"]NHibernate is based on Hibernate 2.1 and so does not support stored procedures.[/quote]

Thankyou for your answer.
I understand.

Hibernate3 to NHibernateX is there planned?

Does anyone know?


Top
  
 
 Post subject:
PostPosted: Fri Sep 09, 2005 12:41 pm 
Beginner
Beginner

Joined: Thu May 12, 2005 3:41 am
Posts: 24
Location: London, UK
Depending on how you want to use the stored procedures, there are some options.

You can call a stored procedure directly using the session's connection property. Suppose that you have a SP that returns a value:
Code:
System.Data.IDbCommand cmd = session.Connection.CreateCommand();
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.CommandText = "MyStoredProc";
long result = (long)cmd.ExecuteScalar();

You will need to be careful of a stored procedure that modifies data.

If you need to use stored procedures that return data to create objects, consider converting them to user-defined functions. These can then be called using a SQL query, or even by mapping a class to the function:
Code:
<class name="MyFunction" table="MyFunction()" mutable="false">
...

or even with parameters:
Code:
<class name="TypeA" table="MyFunc('A')" mutable="false">
...
</class>
<class name="TypeB" table="MyFunc('B')" mutable="false">
...
</class>

This will only work for immutable classes, as there is no way to update tha data tables with this method.


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.