5

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?

rae1
  • 6,066
  • 4
  • 27
  • 48
inutan
  • 10,558
  • 27
  • 84
  • 126

4 Answers4

5

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?

Community
  • 1
  • 1
Aim Kai
  • 2,934
  • 1
  • 22
  • 34
  • Thanks for providing links, I found the article at http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/, cleared doubt simply :-) – inutan Mar 07 '11 at 12:22
2

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.

kprobst
  • 16,165
  • 5
  • 32
  • 53
  • 3
    NH doesn't use castle for dependency injection, it only uses castle proxy. – jonnii Mar 04 '11 at 17:38
  • @jonnii Actually NH 2.1 supports injection, specifically POCO instantiation from a DI container. I've seen it done with the Castle microkernel. I don't know how widely used that is though. – kprobst Mar 04 '11 at 20:31
  • 1
    I meant it doesn't use it internally to wire itself up. – jonnii Mar 04 '11 at 20:54
1

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.

DanP
  • 6,310
  • 4
  • 40
  • 68
0

As the other answers pointed out, all these providers work.

For what it's worth, the dynamic-update mapping configuration (DynamicUpdate() in FluentNHibernate) seems to work only with Castle.

kay.herzam
  • 3,053
  • 3
  • 26
  • 37