I learn NHibernate 2.1 for a while this morning, meet some trouble with save a one to many relation to sql server.
1. find NHibernate 2.1 force you to config a procy factory property in hibernate config file, you can choose Castle, LinFu, or Sprint.net as proxy. the default castle dependencies has been removed. I have to add follow tag in config as I using castle as proxy:
<property name="proxyfactory.factory_class">
NHibernate.ByteCode.Castle.ProxyFactoryFactory,
NHibernate.ByteCode.Castle
</property>
and I frustrate quite a while to find the NHibernate.ByteCode.Castle.dll from google, finally find it in Nhibernate 2.1 package. faint…..
2.find when the one-to-many relation the saving always failed when transation commit. And find out the parent mapping config file, in bag(or set, or else) tag the columns name should be “child table” column name!! which let me feel so strange. Previously I was roughly consider it should be parent table column’s name, sicene it is in parent mapping config file.
3.find when the one to many save to database, if not use inverse=’true’ in parent mapping config, it will generate 3 types of sql: insert parent, insert child, and update child…. But actually update the child relation is not needed. And some article is describe this issue, link.