本文介绍了升级NHibernate和FNH的DLL - 现在变得“没有persister”例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将我的FNH Automapping项目升级到最新版本的NHibernate和Fluent NHibernate(NH 3.2和FNH 1.3),但是现在我在派生类中得到了无持久异常(尽管基类仍然这个派生类自动映射罚款与旧的DLL(FNH 1.0,NH 2.1.2) - 我没有改变我的映射逻辑或这些类以任何方式。

我通过将新的dll复制到旧的dll上,升级了我的项目,删除了不再需要的dll的引用(例如Antlr 3,Castle)

我正在使用的精确版本:

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位)



与旧的dll一起使用的映射代码,但不包含新的:

  return AutoMap.Assemblies(_assemblies)
//不要映射抽象基类
.IgnoreBase< OfeEntity>()

//只映射OfeEntity的子类
.Where(t => t.IsSubclassOf(typeof(OfeEntity)))

.Conventions.Add(
//级联保存所有实体,所以列表将为
//自动保存
DefaultCascade.All(),

//打开延迟加载,所以只会读取实际上
的数据
DefaultLazy.Always( )
);

编辑



另外,我注意到的一件事情是,我们发现,没有被持续的类被分为2级。也就是说,我有一个以下的类:

pre $ $ $ $ c $ public abstract class OfeEntity
$ b public class OfeMeasurementBase: OfeEntity

public class OfeDlsMeasurement:OfeMeasurementBase

OfeDlsMeasurement是不是被坚持。 OfeMeasurementBase以及其他几个继承自OfeEntity的类正在被持久保存。



旧版本没有问题 - 也许新版本有更多的bug比一个级别的继承?

解决方案

可能会有所帮助。我自己使用它来升级一个项目,它的工作。


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?

解决方案

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.

这篇关于升级NHibernate和FNH的DLL - 现在变得“没有persister”例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 03:23