SA Developer .NET

Welcome to SA Developer .NET Sign in | Join | Help
in Search

why nHibernate?!

Last post 07-29-2008, 17:30 by NCode. 13 replies.
Sort Posts: Previous Next
  •  07-13-2008, 22:57 13318

    why nHibernate?!

    I have done some reading. My question to all you people using nHibernate, if you're using .Net and a Sql Backend, why use nHibernate and not LiNQ to SQL? What are the advantages? Everything I've read so far is just stuff that LiNQ does much quicker. Am I missing something?
    StevenMcD.Net
  •  07-14-2008, 7:09 13321 in reply to 13318

    Re: why nHibernate?!

    nHibernate is an ORM, Linq to SQL is a data access layer. So, they're different things basically. In addition nHibernate does it's mappings from data to code in configuration, allowing you to update your data schema without neccesarily recompiling your code. Linq to SQL does not. Entity Frameworks was supposed to offer the same kinds of features as nHibernate via a Linq mechanism, but as usual, Microsoft severaly fumbled the ball on that one and delivered a pretty dodgy ORM.


    So, until Microsoft sort out EF, if you want an ORM in your App, nHibernate/Active Record still seems the way to go.
     


    "He has all of the virtues I dislike and none of the vices I admire." - Winston Churchill
  •  07-14-2008, 11:30 13328 in reply to 13321

    Re: why nHibernate?!

    ok, then do me a favour and explain what an ORM is, because I'm still battling to find the info. What exactly do you using an ORM for? The description on wikipedia isn't very useful and most other entries I have found use very similar wording.

    What am I missing?
    StevenMcD.Net
  •  07-14-2008, 11:35 13329 in reply to 13321

    Re: why nHibernate?!

    I echo codingsanity's opinion.

    I would also like to point out though that you can still use LINQ with nHibernate, they are not mutually exclusive.

    eg: http://orand.blogspot.com/2008/04/linq-to-nhibernate-in-linqpad.html

     


    Driven Software
  •  07-14-2008, 11:36 13330 in reply to 13328

    Re: why nHibernate?!

    ORM - object relational mapping... My understanding of it is you have classes that map to tables... so if you had a users table, you'd have a users class with properties on it that mapped to the users table. Then, whenever you work with any database table you use it's corresponding object. And you either have CRUD (Create, Read, Update, Delete) methods on your classes which will do all your database work calling stored procs or whatever, or you have manager classes that accept the relevant object as a parameter to do stuff like Select, Insert, Update or Delete. Bottom line is you have:

    - Classes that map to your tables

    - You either have methods on those classes to do all your data manipulation or retrieval or you use manager classes that accept and return those objects to do your data manipulation or retrieval...

    Hope that helps... Cool


    "I would love to change the world, but they won't give me the source code"
    SMS your TO DO list to your email
  •  07-14-2008, 11:43 13331 in reply to 13330

    Re: why nHibernate?!

    Heat_Rash:

    ORM - object relational mapping... My understanding of it is you have classes that map to tables... so if you had a users table, you'd have a users class with properties on it that mapped to the users table. Then, whenever you work with any database table you use it's corresponding object. And you either have CRUD (Create, Read, Update, Delete) methods on your classes which will do all your database work calling stored procs or whatever, or you have manager classes that accept the relevant object as a parameter to do stuff like Select, Insert, Update or Delete. Bottom line is you have:

    - Classes that map to your tables

    - You either have methods on those classes to do all your data manipulation or retrieval or you use manager classes that accept and return those objects to do your data manipulation or retrieval...

    Hope that helps... Cool



    But there's where I get confused because you can do all that through LiNQ.....
    StevenMcD.Net
  •  07-14-2008, 11:47 13333 in reply to 13331

    Re: why nHibernate?!

    Well, a proper ORM is a level up from that. Your mapping is more abstract, and you may have an object that is mapped to two or more tables, or several types all sharing one table. In effect you design your object layer focused on OO concepts, then you design your SQL tables focused on relational concepts. You then use the ORM to map between the two, because OO and relational do NOT map 1:1.

    There are often impedance mismatches between SQL and OO, and the ORM hides the consequences of that. Since Linq to SQL works directly off the DB tables, it is NOT an ORM, it is a data access system. It provides no OO abstractions off your data.

    nHibernate does, and Entity Frameworks does (just badly).


    "He has all of the virtues I dislike and none of the vices I admire." - Winston Churchill
  •  07-14-2008, 11:54 13334 in reply to 13331

    Re: why nHibernate?!

    You will always battle to understand the 'why' of ORM until you understand the fundamentals at play, namely the difference between data-centric and domain-centric approaches to software design.

    I would strongly recommend you download, print out and read this book [1], because it gives you an excellent introduction to the ALT.NET mind- and tool-set, including things like ORM, DDD, TDD, DI, CI etc etc. All the stuff you sadly don't seem to see coming down the channels that South African .NET developers currently get their guidance from (ie official MS channels).

    If there is a need for it I would happily present on these topics at a future SaDev meeting?


    [1] http://codebetter.com/blogs/karlseguin/archive/2008/06/24/foundations-of-programming-ebook.aspx


    Driven Software
  •  07-14-2008, 12:00 13335 in reply to 13334

    Re: why nHibernate?!

    now thats something I can understand! Thanks CodingSanity and KevinT. much appreciated! Really appreciate it!
    StevenMcD.Net
  •  07-15-2008, 9:11 13356 in reply to 13334

    Re: why nHibernate?!

    nice ebook. it has been nicely presented. Thank you
  •  07-16-2008, 10:16 13398 in reply to 13356

    Re: why nHibernate?!

    With all the mini alt.net conferences happening in the world it seems that it is time for an SA one.  The community has to organize however, 'cause if it is MS sanctioned/organized it loses a vital cultural element.  I would think that it would also have to be a 'introduction to' level initially
  •  07-16-2008, 10:33 13401 in reply to 13398

    Re: why nHibernate?!

    Delphiza:
    With all the mini alt.net conferences happening in the world it seems that it is time for an SA one.  The community has to organize however, 'cause if it is MS sanctioned/organized it loses a vital cultural element.  I would think that it would also have to be a 'introduction to' level initially

     As a first, it would default to an 'introduction to' scenario, but I would not like to see the 'content' to be introductory.


    Unscrambling Eggs: Decompiling ASP.NET
  •  07-16-2008, 13:24 13408 in reply to 13401

    Re: why nHibernate?!

    Personally I think the first step should be getting together a core group of individuals who already understand what Alt.net is about and then build out from there.

    I have set up a local portal and emailing list so that it was ready when today arrived:

    http://altdotnet.org.za

    If you are passionate about getting this underway then please check it out and lets start a discussion on the mailing list and see where we can take it!


    Driven Software
  •  07-29-2008, 17:30 13757 in reply to 13408

    Re: why nHibernate?!

    KevinT:

    Personally I think the first step should be getting together a core group of individuals who already understand what Alt.net is about and then build out from there.

    I have set up a local portal and emailing list so that it was ready when today arrived:

    http://altdotnet.org.za

    If you are passionate about getting this underway then please check it out and lets start a discussion on the mailing list and see where we can take it!

     Awesome! Count me in... I'm signing-up to the mailing list as we speak!


    OpenLandscape.wordpress.com
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems