I am newbie to nHibernate.
I need to update info via this object . I am getting error "identifier type mismatch Parameter name: id " on the page load.
Code:
int id = Convert.ToInt32(Request.QueryString["id"]);
Configuration cfg = new Configuration();
cfg.AddAssembly("Domain");
ISessionFactory factory = cfg.BuildSessionFactory();
ISession session = factory.OpenSession();
Coupon objCoupon = null;
objCoupon = (Coupon)session.Load(typeof(Coupon),id); <--- the error
txtCouponTitle.Text = objCoupon.CouponTitle;
imgCoupon.ImageUrl = "uploadimages\\" + objCoupon.CouponImage;
session.Close();
Stack trace:
Code:
[ArgumentException: identifier type mismatch
Parameter name: id]
NHibernate.Engine.Key..ctor(Object id, IType identifierType, Object identifierSpace, Type clazz, Boolean isBatchLoadable) +188
NHibernate.Impl.SessionImpl.DoLoad(Type theClass, Object id, Object optionalObject, LockMode lockMode, Boolean checkDeleted) +231
NHibernate.Impl.SessionImpl.DoLoadByClass(Type clazz, Object id, Boolean checkDeleted, Boolean allowProxyCreation) +185
NHibernate.Impl.SessionImpl.Load(Type clazz, Object id) +37
WebUI.EditCoupon.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\webui\editcoupon.aspx.cs:52
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
HBM.XML File:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<!-- generated using NHibernate.hbm.cst, see http://www.intesoft.net/nhibernate for notes and latest version -->
<class name="Domain.Coupon, Domain" table="Coupon">
<id name="Id" type="Decimal" unsaved-value="0">
<column name="CouponID" sql-type="Int32" not-null="true" unique="true" index="PK_SGCoupon"/>
<generator class="native" />
</id>
<property name="CouponTitle" type="String">
<column name="CouponTitle" length="250" sql-type="varchar" not-null="false"/>
</property>
<property name="CouponImage" type="String">
<column name="CouponImage" length="250" sql-type="varchar" not-null="false"/>
</property>
<property name="CouponType" type="Byte">
<column name="CouponType" sql-type="tinyint" not-null="false"/>
</property>
<many-to-one name="Store" class="Domain.Store, Domain">
<column name="StoreId" sql-type="numeric" not-null="false"/>
</many-to-one>
</class>
</hibernate-mapping>
Any solution to this? Am I going somewhere wrong with the Session.Load()?