-->
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.  [ 3 posts ] 
Author Message
 Post subject: Request to help to call a SQL Server Stored Procedure
PostPosted: Tue Jan 06, 2009 6:00 pm 
Newbie

Joined: Wed Dec 10, 2008 2:14 pm
Posts: 17
Hi,
I am new with hibernate objects.
I have to call a SQL Server Stored procedure, I tried a lot but couldnot do this, so request to help me for .hbm and .cs file and pls tell me how to call this stored procedure with parameters ?

I would like to request if someone can tell me exact syntex for .hbm file and code to call this stored procedure.

#########################################

ALTER PROCEDURE [dbo].[RulesDetails_Get]
(
@ELAID INT ,
@FamilyID INT ,
@GroupID INT ,
@SubGroupID INT ,
@ItemComponentID INT ,
@ComponentID INT
)
AS
BEGIN

SELECT
QtyAlreadyOrdered_Component,
QtyAlreadyOrdered_Family,
QtyAlreadyOrdered_Group ,
QtyAlreadyOrdered_SubGroup,
QtyAlreadyOrdered_ELA ,

MaxQtyAllowed_Component ,
MaxQtyAllowed_Family ,
MaxQtyAllowed_Group ,
MaxQtyAllowed_SubGroup ,
MaxQtyAllowed_ELA ,

QtyBalanceAvailable_Component,
QtyBalanceAvailable_Family,
QtyBalanceAvailable_Group,
QtyBalanceAvailable_SubGroup,
QtyBalanceAvailable_ELA
FROM
MyTable1
WHERE
ELAID = @ELAID
AND
FamilyID = @FamilyID



#########################################


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 07, 2009 12:03 am 
Regular
Regular

Joined: Wed Oct 15, 2008 6:59 am
Posts: 103
Location: Chennai
take a view this

http://www.hibernate.org/187.html

http://www.coderanch.com/t/216142/Objec ... -hibernate

_________________
If u feel it will help you, don't forget to rate me....


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 07, 2009 12:14 pm 
Newbie

Joined: Wed Dec 10, 2008 2:14 pm
Posts: 17
Hi, Really thanks for your reply and very good links.
But actually I checked everything but still not sure what's wrong I did.
Here is my .hbm file.


Code:
<?xml version="1.0" encoding="utf-8" ?>
<!-- Generated by MoreGen 28-Apr-2008 11:27:28 -->
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" >


   <sql-query name="RulesDetails_Get" >
      <return alias="RulesDetails_Get" class="ELADAO.RulesDetails_Get, ELADAO">
         <return-property name="QtyAlreadyOrdered_Component" column="QtyAlreadyOrdered_Component"></return-property>
         <return-property name="QtyAlreadyOrdered_Family" column="QtyAlreadyOrdered_Family"></return-property>
         <return-property name="QtyAlreadyOrdered_Group" column="QtyAlreadyOrdered_Group"></return-property>
         <return-property name="QtyAlreadyOrdered_SubGroup" column="QtyAlreadyOrdered_SubGroup"></return-property>
         <return-property name="QtyAlreadyOrdered_ELA" column="QtyAlreadyOrdered_ELA"></return-property>
         
         <return-property name="MaxQtyAllowed_Component" column="MaxQtyAllowed_Component"></return-property>
         <return-property name="MaxQtyAllowed_Family" column="MaxQtyAllowed_Family"></return-property>
         <return-property name="MaxQtyAllowed_Group" column="MaxQtyAllowed_Group"></return-property>
         <return-property name="MaxQtyAllowed_SubGroup" column="MaxQtyAllowed_SubGroup"></return-property>
         <return-property name="MaxQtyAllowed_ELA" column="MaxQtyAllowed_ELA"></return-property>
         
         <return-property name="QtyBalanceAvailable_Component" column="QtyBalanceAvailable_Component"></return-property>
         <return-property name="QtyBalanceAvailable_Family" column="QtyBalanceAvailable_Family"></return-property>
         <return-property name="QtyBalanceAvailable_Group" column="QtyBalanceAvailable_Group"></return-property>
         <return-property name="QtyBalanceAvailable_SubGroup" column="QtyBalanceAvailable_SubGroup"></return-property>
         <return-property name="QtyBalanceAvailable_ELA" column="QtyBalanceAvailable_ELA"></return-property>


      </return>
      <!--
      { call RulesDetails_Get(?,:ELAID, ?,:FamilyID, ?,:GroupID, ?,:SubGroupID, ?,:ItemComponentID, ?,:ComponentID) }
          
           -->

      { call RulesDetails_Get(:ELAID, :FamilyID, :GroupID, :SubGroupID, :ItemComponentID, :ComponentID) }
   </sql-query>

   </hibernate-mapping>





And I also have class file.
And Here is my code to call it.

Code:
NHibernate.ISession hibSession = null;

hibSession = getHibSession();

IQuery q = hibSession.GetNamedQuery("RulesDetails_Get");

q.SetParameter("ELAID", 7);
q.SetParameter("FamilyID", 28);
q.SetParameter("GroupID", 79);
q.SetParameter("SubGroupID", 219);
q.SetParameter("ItemComponentID", 584);
q.SetParameter("ComponentID", 563);

IList results =   q.List();



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