添加Net4CollectionTypeFactory的原因

.NET4.0已经实现了该功能

http://jahav.com/blog/nhibernate-using-net-4-iset/

NHibernate using .NET 4 ISet

0 Comments

NHibernate 4.0 (released in 2014-08-17) has brought us support for .NET 4 ISet<> collections, thus freeing us from the tyranny of the Iesi package. But long before that, there was a way to use .NET 4 ISet in you NHibernate 3 projects:

NHibernate.SetForNet4

SetForNet4 is a NuGet package you can install into your application. Once you install it, there will be a new file with a implementation of a ICollectionTypeFactory in your project that will support System.Collections.Generic.ISet<> instead of Iesi.Collections.Generic.ISet<>. Other than that, it is basically a copy of the original DefaultCollectionTypeFactory.

All you need to do after installation is to set the configuration property “collectiontype.factory_class” to the assembly qualified name of the created factory, make sure the dll with the created collection factory can be loaded (if you have it in separate project) and all will be peachy.

I had slight trouble with configuration, I have configuration spread over the XML and the code and the comment at the top said to add line to my configuration:

//add to your configuration: //configuration.Properties[Environment.CollectionTypeFactoryClass] //        = typeof(Net4CollectionTypeFactory).AssemblyQualifiedName

Since it was integral part of the configuration (not the db dialect or something), I put it to the code

var configuration = new Configuration().Configure(); configuration.Properties[Environment.CollectionTypeFactoryClass]      = typeof(Net4CollectionTypeFactory).AssemblyQualifiedName; 

… and it didn’t work. I had to set the factory before I made configured from XML.

var configuration = new Configuration()     .SetProperty(Environment.CollectionTypeFactoryClass, typeof(Net4CollectionTypeFactory).AssemblyQualifiedName)     .Configure()

I am not exactly sure why, but I think it is because I also have assemblies with *hbm.xml mapping files specified in the XML using <mapping assembly="EntityAssembly" /> tags.

The configuration code have set the collection factory of the bytecode provider before the mapped assemblies were processed.

Downside

It should be noted that using SetForNet4 package, you can’t use both, the Iesi and the .NET4 collections at the same time, thus you need to replace the Iesi in the whole application. Also, we have NH 4.0 now, so doing this is kind of pointless, but I did it before 4.0 and I don’t have time to upgrade to 4.0 and check that my app still works as advertised.

时间: 2024-10-14 19:57:23

添加Net4CollectionTypeFactory的原因的相关文章

CSS3 @font-face的url要添加?#iefix的原因

转至:https://github.com/CSSLint/csslint/wiki/Bulletproof-font-face When using @font-face to declare multiple font types for cross browser compatibility, you can see 404's in old versions of IE due to a bug in the way that IE parses the font declaration

单电源运放添加偏置电压的原因

运放的特点是输出幅值不能超过电源电压的压差,对于传统单电源运放,如LM358,输出电压幅值不能达到电源电压上下限. 单电源运放工作时只能放大对地为正(同向输入)或为负(反向输入)的直流电压,若输入为对地的交流信号时,则只能放大正半波或负半波,另一半波会因为截止而产生严重失真. 为了得到不失真的交流放大信号,需要在输入端叠加一个偏置电压,一般为1/2 VCC. 若在运放的一端输入对地偏置1/2 VCC的信号,另一端接地,则在反向输入的情况下:理论输出为负,但在此情况下单电源运放的下限接近0V,因此

Giraph添加应用程序Weakly Connected Components算法

本人原创,转载请注明出处! 本人QQ:530422429,欢迎大家指正.讨论. 目的:举例说明如何在Giraph中添加应用程序,以WCC(Weakly Connected Components)算法为例,描述怎么添加Vertex的子类,自定义输入输出格式和使用Combiner等. 背景:Giraph源码中自带有WCC算法,类为:org.apache.giraph.examples.ConnectedComponentsVertex,代码如下: package org.apache.giraph.

c#实现任务栏添加控制按钮

Windows7Taskbar的使用 你需要引入3个文件VistaBridgeLibrary.dll.Windows7.DesktopIntegration.dll.Windows7.DesktopIntegration.Registration.exe 下载地址:http://yunpan.cn/QauRaNK4H3BYW (提取码:fe58) 里面封装好的类:Windows7Taskbar.ThumbButtonManager.ThumbButton.JumpListManager.Regi

【SpringMVC学习04】Spring、MyBatis和SpringMVC的整合

前两篇springmvc的文章中都没有和mybatis整合,都是使用静态数据来模拟的,但是springmvc开发不可能不整合mybatis,另外mybatis和spring的整合我之前学习mybatis的时候有写过一篇,但是仅仅是整合mybatis和spring,所以这篇文章我系统的总结一下spring.mybatis和springmvc三个框架的整合(后面学习到maven时,我会再写一篇使用maven整合的文章,这篇没有用到maven). 1. jar包管理 我之前有写过一篇spring.hi

深入剖析java并发之阻塞队列LinkedBlockingQueue与ArrayBlockingQueue

关联文章: 深入理解Java类型信息(Class对象)与反射机制 深入理解Java枚举类型(enum) 深入理解Java注解类型(@Annotation) 深入理解Java类加载器(ClassLoader) 深入理解Java并发之synchronized实现原理 Java并发编程-无锁CAS与Unsafe类及其并发包Atomic 深入理解Java内存模型(JMM)及volatile关键字 剖析基于并发AQS的重入锁(ReetrantLock)及其Condition实现原理 剖析基于并发AQS的共

React Native 之极光推送jpush-react-native 手把手配置

这是 react native 配置极光推送使用的组件,比较常用https://github.com/jpush/jpush-react-native 先把组件地址贴出来,方便大家使用参考.如果这个大家不能配置成功,欢迎大家一起入坑交流,有问题联系 QQ379038610(添加备注说明原因) 不扯没用的,还要洗洗睡觉,直接把自己配置iOS极光的步骤给大家贴出来 1,首先大家项目环境,签名证书什么都配置完毕,开始集成推送的前提下 在项目当前目录执行: npm install jpush-react

Magento开发经验总结(一、 初初见你——产品属性集搜索模块)

一. 初初见你——产品属性集搜索模块 产品属性搜索模块作为我第一个开发的定制功能模块,对于我个人理解magento系统内部规则与机制.二次开发规则等具有极其重要的意义.可以这么说,通过此模块的开发,我轻轻叩开了magento系统开发的大门,第一次看到了门内复杂.深邃.丰富及灵活的运行机制. 在门外徘徊的我感触良多,magento上手难这件事情我真真切切得感受到了,但是一旦入了门,我们可以从过程中学到非常多的东西,如深入理解设计模式.构建软件理论.模式设计.领域驱动设计等等. 1. 功能需求:新创

EntityFramework学习

本文档主要介绍.NET开发中两项新技术,.NET平台语言中的语言集成查询技术 - LINQ,与ADO.NET中新增的数据访问层设计技术ADO.NET Entity Framework.ADO.NET的LINQ to Entity部分以LINQ为基础,为了完整性首先介绍LINQ技术. 预备知识 LINQ技术 LINQ是.NET 3.5中新增的一种技术,这个技术扩展了.NET平台上的编程语言,使其可以更加方便的进行数据查询,单纯的LINQ技术主要完成对集合对象(如System.Collection下