问题
I'm trying to upgrade my FNH Automapping project to the latest versions of NHibernate and Fluent NHibernate (NH 3.2 and FNH 1.3), but now I get a "no persister" exception on a derived class (though the base class still seems to be persisted properly).
This derived class Automapped fine with the old dlls (FNH 1.0, NH 2.1.2) - I have not changed my mapping logic or these classes in any way.
I upgraded my project by just copying the new dlls over the old ones, and deleting references to dlls that are no longer needed (e.g. Antlr 3, Castle) by the new dlls.
Exact versions I'm using:
NHibernate 3.2.0.4000
FluentNHibernate 1.3.0.0
System.Data.SQLite 1.0.76.0
VS 2008 9.0.30729.1 SP
Windows XP SP3 (32 bit)
The mapping code that works with the old dlls, but not with the new ones:
return AutoMap.Assemblies(_assemblies)
// Don't map the abstract base class
.IgnoreBase<OfeEntity>()
// Only map subclasses of OfeEntity
.Where(t => t.IsSubclassOf(typeof(OfeEntity)))
.Conventions.Add(
// Do cascading saves on all entities so lists will be
// automatically saved
DefaultCascade.All(),
// Turn on lazy loading, so will only read data that is actually
// displayed
DefaultLazy.Always()
);
Edit:
After turning FNH Diagnostics on, I can see that FNH is not creating a table for my derived class with the new dlls.
Also, one thing I noticed - the class that is not being persisted is subclassed by 2 levels. That is, I have a the following classes:
public abstract class OfeEntity
public class OfeMeasurementBase : OfeEntity
public class OfeDlsMeasurement : OfeMeasurementBase
OfeDlsMeasurement is the class that is not being persisted. OfeMeasurementBase, as well as several other classes that inherit from OfeEntity, are being persisted properly.
Old versions had no problem with this - maybe new versions have a bug when there's more than one level of inheritance?
回答1:
I migrated our project from some older (F)NH to the latest NH 3.2. I suspect it now uses different key field names in collections and such, because I need to specify exact column names when using the existing database.
Also, I suggest rebuilding Fluent NHibernate from sources with NHibernate 3.2 just to be sure everything gets in the place.
回答2:
The article How to upgrade your apps to NHibernate 3.2 with Fluent NHibernate 1.2 may be helpful. I used it myself to upgrade a project and it worked.
来源:https://stackoverflow.com/questions/8041881/upgraded-nhibernate-and-fnh-dlls-now-getting-no-persister-exceptions