-->
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.  [ 1 post ] 
Author Message
 Post subject: Using Stored Procedures with NHibernate
PostPosted: Mon Oct 15, 2007 8:20 am 
Beginner
Beginner

Joined: Tue Sep 11, 2007 5:57 am
Posts: 36
Hello,

I am using NHibernate1.2 and SQL Server, and have a problem with executing SP's.

Class Person
{

Guid PersonUID;
string LastName;
string FirstName;
Guid AddressUID

}

Class Address
{

Guid AddressUid;
string Address1;
string City;
string State;

}


Now I create a SP as

CREATE PROCEDURE [dbo].[pr_GetPersonDetails]
@PersonUID uniqueidentifier
AS
SET NOCOUNT ON

SELECT PersonUID ,LastName,Add.City FROM Person Per
INNER JOIN Address Add ON Add.AddressUID=Per.AddressUID WHERE
PersonUID =@PersonUID
GO


Now I add this to register pr_GetPersonDetails

<sql-query name="pr_GetPersonDetails">
<return alias="Per" class="NHibernateTest.Person,NHibernateTest">
<return-property name="PersonUID" column="PersonUID"></return-property>
<return-property name="LastName" column="LastName"></return-property>
<return-property name="City" column="City"></return-property>
</return>
exec pr_GetPersonDetails ?
</sql-query>


My Question is Do I need to collect the result set returned by the stored procedure in a class that matches the result set defination.
Meaning If my SP returns all columns from Person table and I collect the result set in Type Person it works. But if I execute the above mentioned SP I get an ADO Exception.

If my SP returns PersonUID ,LastName,City,
Then do I need to have a class defined with these 3 columns(properites), as say PersonDetails?


In the above case I can replace the SP with a view , but we have a lot complicated SP which can't be replaced by views.

Please advise.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.