Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the relationship between Castle, LinFu and Spring with NHibernate?

Tags:

nhibernate

I am a newbie to NHibernate and a bit confused about Castle, LinFu and Spring.

I understand that NHibernate helps in DDD and one can map entities to database using xml or Fluent NHibernate. But wondering how Castle, LinFu and Spring are associated to NHibernate.

Can anyone please shed some light or can point to any web link?

like image 575
inutan Avatar asked Mar 04 '11 17:03

inutan


3 Answers

Personally I have used Castle and LinFu. I tended to use Castle if I was using other Castle components as well, such as Windsor. In fact Castle have an NHibernate facility as well which can be helpful. I used LinFu when I didn't use any other Castle components.

This blog post is slightly old but has some useful information on it: http://nhforge.org/blogs/nhibernate/archive/2008/11/09/nh2-1-0-bytecode-providers.aspx

Check out the answer to these questions:

What are the differences between LinFu.DynamicProxy and Castle.DynamicProxy?

NHibernate proxy class, what should I choose?

NHibernate 2.1 Proxy Factory options - what are the differences and which to choose?

like image 166
Aim Kai Avatar answered Nov 16 '22 21:11

Aim Kai


Castle and the others are used by NH to perform dependency injection and type interception. NH is able to lazy-load data for example, because it creates proxies to your own types and intercepts calls to them. That way it can make DB calls and populate instances in a sort of automagical way.

All three of them do basically the same thing; it's up to you to decide which one you prefer.

like image 36
kprobst Avatar answered Nov 16 '22 23:11

kprobst


Although all seem comparable at first glance, I've personally avoided Linfu due to the following issue with S#arp Arhciture. This one bit me bad enough that I've been forever gun-shy. The Castle provider has never steered me wrong.

like image 1
DanP Avatar answered Nov 16 '22 21:11

DanP