Stored Procedure

Andy's Avatar

Andy

27 Feb, 2010 05:28 PM via web

Hi,
Could anybody tell me how to map a stored procedure that inserts.
I found out how to map a stored procedure that selects in a hbm.xml file, but i can't get my insert stored procedure to work with the same mapping method.

My select stored procedure mapping:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<sql-query name="stp_Get_Something">

<return alias="Something" class="Namespace.ClassSomething, MyAssembly">
  <return-property name="Id" column="Id"></return-property>
  <return-property name="Info" column="Info"></return-property>
</return>
call stp_Get_Something(:parameters)

</sql-query> </hibernate-mapping>

thanks,
Andy

  1. Support Staff 2 Posted by Paul Batum on 01 Mar, 2010 09:27 AM

    Paul Batum's Avatar

    The way I did this is to use SqlInsert to call the stored procedure. I don't have the code in front of me but it was something like:

    public class CustomerMap : ClassMap<Customer>
    {
        public CustomerMap()
        {
            Id(x => x.CustomerId);     
            SqlInsert("exec sp_InsertCustomer ? ? ?");
        }
    }
    
  2. James Gregory closed this discussion on 18 Mar, 2010 12:17 PM.

Comments are currently closed for this discussion. You can start a new one.