Stored Procedures in FluentNHibernate 1.1
Hello,
in the release notes of the newest version I saw that it should be possible to use stored procedures in FluentNHibernate.
Could anybody give me a short example how to implement a stored procedure in a mapping file without using a XML file?
We would like to use the stored procedures for selects with some parameters.
Thanks in advance!
Support Staff 2 Posted by Paul Batum on 05 Jun, 2010 10:53 AM
Unfortunately the current support for using stored procedures is via the
SqlInsert, SqlUpdate, SqlDelete methods. None of those are applicable to
using a stored procedure to a do a select. Unless there's a backdoor that
I'm unaware of, you can't do this with Fluent NH.
3 Posted by Wetz, Marco SP/HZA-EMEP on 05 Jun, 2010 10:56 AM
Thank you for your e-mail. I will be back on 2010-06-07. Please note that my e-mails will not be read or forwarded. For urgent queries please contact Mr. Uwe Beck, SP/HZA-EMEP. Thank you.
Danke für Ihre E-Mail. Ich bin zurück am 2010-06-07. E-Mails werden nicht gelesen oder weitergeleitet. Bitte wenden Sie sich in dringenden Fällen an Herrn Uwe Beck, SP/HZA-EMEP.
Kind regards / Freundliche Grüße
Schaeffler Technologies GmbH & Co. KG
Marco Wetz
4 Posted by Marco on 10 Jun, 2010 01:02 PM
First thanks for your answer and sorry for the "Out of office reply".
Currently i can work with flunt for the normal entities and standard xml for the stored procedures. But it would be useful to have both in fluent. Do you have selects from stored procedures in your todo list for future releases?
best regards
Marco
Support Staff 5 Posted by Paul Batum on 13 Jun, 2010 04:22 AM
I'm not actually sure how you would go about doing this using plain old
nhibernate xml. Can you show me the necessary xml?
6 Posted by Marco on 14 Jun, 2010 06:07 AM
Hello Paul,
no problem, here it is:
<?xml version='1.0' encoding='utf-8'?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="MaQS.DatabaseAccess.Mapping" assembly="MaQS.DatabaseAccess.Mapping">
<sql-query name="TestProc" callable="true">
</sql-query> </hibernate-mapping>
The call in the code looks like that:
IList list = NHibernateSessionManager.Instance.Session.GetNamedQuery("TestProc ")
It is only a short sample with one parameter value.
Thanks in advance!
Best regards
Marco
7 Posted by Marco on 14 Jun, 2010 06:24 AM
Hello Paul,
sorry but i have some problems with autoformat of the list. Maybe you can delete the last post?
Here again:
The xml ist attached
The call in the code looks like that:
IList list = NHibernateSessionManager.Instance.Session.GetNamedQuery("TestProc ").SetInt32("ID", 15).List();
It is only a short sample with one parameter value.
Thanks in advance!
Best regards
Marco