NHibernate.MappingException on table insertion.

Posted by Suja on Stack Overflow See other posts from Stack Overflow or by Suja
Published on 2011-01-14T06:50:25Z Indexed on 2011/01/14 6:53 UTC
Read the original article Hit count: 229

Filed under:

The table structure is :

alt text

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??

© Stack Overflow or respective owner

Related posts about nhibernate-mapping