1

here is code, how I am calling Stored procedure

ISession session = NHibernateHelper.GetCurrentSession();
        IQuery q = session.GetNamedQuery("ps_getProgressBarData1");
        var t = q.List();

XML mapping

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"   namespace="ReleaseDAL"  assembly="ReleaseDAL">

 <sql-query name="ps_getProgressBarData1">
    <return alias="ProgressBar" class="ProgressBar">
      <return-property name="Tot" column="Tot"/>
      <return-property name="subtot" column="subtot"/>
    </return>
    exec ps_getProgressBarData1
  </sql-query>
</hibernate-mapping>

Class mapping

public virtual Int32 Tot {get { return _Tot; } set { _Tot = value; } }
    public virtual Int32 subtot { get { return _subtot; } set { _subtot = value; }}

I am getting exception: No persister for: ReleaseDAL.ProgressBar, ReleaseDAL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

Please tell me what is the issue here?

Thanks

Muhammad Akhtar
  • 51,913
  • 37
  • 138
  • 191

2 Answers2

2

You could get that error you don't have the mapping file marked as embedded resource. Please check that as first thing.

Claudio Redi
  • 67,454
  • 15
  • 130
  • 155
  • yes, that's very good point, now I am getting this issue -------No persister for: ReleaseDAL.ProgressBar, ReleaseDAL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null – Muhammad Akhtar Apr 21 '10 at 14:42
  • Please check this other question on the site and tell me if works for you http://stackoverflow.com/questions/57804/nhibernate-mappingexception-no-persister-for – Claudio Redi Apr 21 '10 at 14:48
  • no, this is not working for me. I have already check this. I am upvoting becoz ur first clue working for, now I am getting other issue of No persister for: ReleaseDAL.ProgressBar – Muhammad Akhtar Apr 21 '10 at 14:57
  • The class ProgressBar is on the namespace "ReleaseDAL"? – Claudio Redi Apr 21 '10 at 15:03
  • Sorry, I'm running out of ideas. Maybe you can paste the ProgressBar mapping and check also if this mapping file is marked as embedded resource – Claudio Redi Apr 21 '10 at 15:18
1

Well you don't have a mapping for ProgressBar (it's not an entity I suppose), so probably you just want a DTO as a result from the query.

So you just have to map the result as scalars, and in the query define a transformer.

 <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="ReleaseDAL"  assembly="ReleaseDAL">

 <sql-query name="ps_getProgressBarData1">
      <return-scalar column="Tot" Type="xxx"/>
      <return-scalar column="subtot" Type="xxx"/>

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

and in the query methode:

query.SetResultTransformer(Transformers.AliasToBean(typeof(ProgressBar )));
query.List()
Boklucius
  • 1,896
  • 17
  • 19