NHibernate.MappingException on table insertion.
- by Suja
The table structure is :
The controller action to insert a row to table is
public bool CreateInstnParts(string data)
{
IDictionary myInstnParts = DeserializeData(data);
try
{
HSInstructionPart objInstnPartBO = new HSInstructionPart();
using (ISession session = Document.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
objInstnPartBO.DocumentId = Convert.ToInt32(myInstnParts["documentId"]);
objInstnPartBO.InstructionId = Convert.ToInt32(myInstnParts["instructionId"]);
objInstnPartBO.PartListId = Convert.ToInt32(myInstnParts["part"]);
objInstnPartBO.PartQuantity = Convert.ToInt32(myInstnParts["quantity"]);
objInstnPartBO.IncPick = Convert.ToBoolean(myInstnParts["incpick"]);
objInstnPartBO.IsTracked = Convert.ToBoolean(myInstnParts["istracked"]);
objInstnPartBO.UpdatedBy = User.Identity.Name;
objInstnPartBO.UpdatedAt = DateTime.Now;
session.Save(objInstnPartBO);
transaction.Commit();
}
return true;
}
}
catch (Exception ex)
{
Console.Write(ex.Message);
return false;
}
}
This is throwing an exception
NHibernate.MappingException was caught
Message="No persister for: Hexsolve.Data.BusinessObjects.HSInstructionPart"
Source="NHibernate"
StackTrace:
at NHibernate.Impl.SessionFactoryImpl.GetEntityPersister(String entityName)
at NHibernate.Impl.SessionImpl.GetEntityPersister(String entityName, Object obj)
at NHibernate.Event.Default.AbstractSaveEventListener.SaveWithGeneratedId(Object entity, String entityName, Object anything, IEventSource source, Boolean requiresImmediateIdAccess)
at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event)
at NHibernate.Event.Default.DefaultSaveEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event)
at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.EntityIsTransient(SaveOrUpdateEvent event)
at NHibernate.Event.Default.DefaultSaveEventListener.PerformSaveOrUpdate(SaveOrUpdateEvent event)
at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.OnSaveOrUpdate(SaveOrUpdateEvent event)
at NHibernate.Impl.SessionImpl.FireSave(SaveOrUpdateEvent event)
at NHibernate.Impl.SessionImpl.Save(Object obj)
at HexsolveMVC.Controllers.InstructionController.CreateInstnParts(String data) in F:\Project\HexsolveMVC\Controllers\InstructionController.cs:line 1342
InnerException:
Can anyone help me solve this??