title: NHibernate.MappingException - Trouble Shooting Checklist (no persister for)
body: <p>Here's a starter list:  </p>
  
  <ol>
  <li>if hbm is hand generated, is it an embedded resource?</li>
  <li>if using FNH, does it pass a PerssistenceSpecification test?  </li>
  <li>if not using FNH, can you save and then load the persisted class?  </li>
  <li>use Ayende's <a href="http://ayende.com/Blog/archive/2006/08/09/NHibernateMappingCreatingSanityChecks.aspx" rel="nofollow noreferrer">"sanity checks"</a></li>
  </ol>
  
  <p>I'm sure many of you have gotten this one at one point or another. But have you ever gotten it when you <em>knew</em> your mapping was set up correctly?</p>
  
  <p>I started getting this exception after I started using a new repository design, but only in one scenario! PersistenceSpecification tests pass, as do all repository methods (using SQLite).</p>
  
  <p>The scenario that leads to the exception is when legacy projects from a different db are converted to green field system. The legacy system is from a different database and has it's own session factory, which should be irrelevant because the error comes after previously unconverted Projects are retrieved and in memory.</p>
  
  <p>As the routine tries to save these unconverted Projects into the new database, the exception is thrown, full stack trace below.</p>
  
  <p>Any ideas on how to build up the trouble shooting check list and solves this problem?</p>
  
  <p>Cheers,
  Berryl </p>
  
  <p>=== the Exception trace =====</p>
  
  <pre><code>failed: NHibernate.MappingException : No persister for: Smack.ConstructionAdmin.Domain.Model.Projects.Project
  at NHibernate.Impl.SessionFactoryImpl.GetEntityPersister(String entityName)
  at NHibernate.Impl.SessionImpl.GetEntityPersister(String entityName, Object obj)
  at NHibernate.Engine.ForeignKeys.IsTransient(String entityName, Object entity, Nullable`1 assumed, ISessionImplementor session)
  at NHibernate.Event.Default.AbstractSaveEventListener.GetEntityState(Object entity, String entityName, EntityEntry entry, ISessionImplementor source)
  at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.PerformSaveOrUpdate(SaveOrUpdateEvent event)
  at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.OnSaveOrUpdate(SaveOrUpdateEvent event)
  at NHibernate.Impl.SessionImpl.FireSaveOrUpdate(SaveOrUpdateEvent event)
  at NHibernate.Impl.SessionImpl.SaveOrUpdate(Object obj)
  NHibernate\Repository\FabioNHibRepository.cs(46,0): at Smack.Core.Data.NHibernate.Repository.FabioNHibRepository`1.Add(T item)
  LegacyConversion\LegacyBatchUpdater.cs(20,0): at Smack.ConstructionAdmin.Data.LegacyConversion.LegacyBatchUpdater.ConvertOpenLegacyProjects(ILegacyProjectDao legacyProjectDao, IProjectRepository greenProjectRepository)
  Data\Brownfield\ProjectBatchUpdate_SQLiteTests.cs(19,0): at Smack.ConstructionAdmin.Tests.Data.Brownfield.ProjectBatchUpdate_SQLiteTests.Test()
  </code></pre>