views:

97

answers:

1

I am getting exception when calling Stored Procedure using Nhibernate and here is the exception

No persister for: ReleaseDAL.ProgressBars, ReleaseDAL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

here is class file

 public class ProgressBars
{
    public ProgressBars()
    { }
    private Int32 _Tot;
    private Int32 _subtot;
    public virtual Int32 Tot {get { return _Tot; } set { _Tot = value; } }
    public virtual Int32 subtot { get { return _subtot; } set { _subtot = value; }}
}

here is my mapping file

<hibernate-mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:nhibernate-mapping-2.2"
               assembly="ReleaseDAL" namespace="ReleaseDAL" > 
 <sql-query name="ps_getProgressBarData1" >
    <return alias="ProgressBars" class="ProgressBars">
      <return-property name="Tot" column="Tot"/>
      <return-property name="subtot" column="subtot"/>
    </return>
    exec ps_getProgressBarData1
  </sql-query>
</hibernate-mapping>

Calling Code

 public List<ProgressBars> getProgressBarData1(Guid ReleaseId)
    {
        ISession session = NHibernateHelper.GetCurrentSession();
        List< ProgressBars> progressBar = (List<ProgressBars>)session.GetNamedQuery("ps_getProgressBarData1").List<ProgressBars>();
        NHibernateHelper.CloseSession();
        return progressBar;
    }

here is my output column from stored procedure its Tot,subtot

I am introuble due to this exception, I did lot Google but no success, Please give idea to solve this problem.

Thanks.........

A: 

I was missing to add class in mapping file like..

    <class name="ProgressBars" table="tbl" lazy="true" >
    <id name="Tot" column="Tot" type="int">
      <generator class="native" />
    </id>
    <property name="Tot" column="Tot" type="Int32" />
    <property name="subtot" column="subtot" type="Int32" />
  </class>

  <sql-query name="ps_getProgressBarData" >
    <return alias="Prog" class="ProgressBars">
      <return-property name="Tot" column="Tot" />
      <return-property name="subtot" column="subtot" />
    </return>


     exec ps_getProgressBarData ?
      </sql-query>
Muhammad Akhtar
This is kind of strange. When you have a regular mapping for ProgressBars, why do you need this stored procedure?
Stefan Steinegger
I am run SP without regular mapping class, but it is not working for, then I decide to make regular class plus.
Muhammad Akhtar