Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nHibernate versus LLBLGen Pro

I am trying to work out with ORM tool to move over to and have narrowed it down to two candidates.

nHibernate or LLBLGen Pro

Please can you guys give me pros and cons in using both these tools especially if you have experience in both. I am not really interested in any other tools but am wanting some heads up so I can decide which tool to spend time learning....

I already know that one is free and one isn't, I also know that nHibernate might take some learning....

Many thanks, Richard

like image 426
Rippo Avatar asked Jul 11 '09 17:07

Rippo


2 Answers

I have used both. At first I was sold on nHibernate and refused to try anything else even though I knew about other options.

With LLBLGen Pro, I was skeptical, but soon saw the advantages as well. I have not totaly abandoned nHibernate. I will continue to keep int in my "box of tools". I have found LLBLGen useful in some cases especially when interacting with a database that already exists and you have no choice of re-designing it. It takes less than an hour (depending on size of database of course) to generate my LLBLGen Entity Objects from the database, as opposed to having to code all of it manually with nHibernate, AND do the mappings. nHibernate is missing a nice graphical interface to create the mappings. This fact becomes even more important when the database is massive with thousands of tables that you need to potentially access in your application.

Although LLBLGen is more of a Data Access Layer generator (And I am not normally a fan of DAL generators), it has a lot of features a "true ORM" tool would have. In my opinion it has the best of both worlds. Once you start working with it you start to realize that it is very flexible and extendable. One part I like a lot is that it is possible for me to create partial classes for the generated entity objects, where I can code in my business logic, as well as validation.

The code generation is templated so you have full control over the code it generates. With nHibernate I find myself writing some of the same kind of code over and over again. With LLBLGen I can generate it and get to focus on business logic and issues quicker.

For someone who is just starting to use ORM type tools, I really recommend to start with LLBLGen, because nHibernate can be overwhelming. And in the end you will have achieved the same result (More or less).

Edit #1: LLBLGen now also has 100% support for LINQ. (So if you like LINQ to SQL for that reason) further LLBLGen can support many databases, where LINQ to SQL is only for Microsoft SQL Database.

Edit #2: According to Graviton you can use CodeSmith to do some of the code generating for you for nHibernate. That is really cool, but for a newcomer to ORM I would still recommend LLBLGen. To me that is adding more dependencies where LLBLGen has it all in one package. Also like I said before the learning curve is so much less steep and you will get the same benefits, which will also help you ease in to nHibernate if you ever decide to go there.

like image 57
7wp Avatar answered Sep 21 '22 22:09

7wp


The major difference is that LLBLGen is a code generator, while NHibernate is a "true" ORM library.

LLBLGen advantages:

  • Easy to use model designer. Can import your existing database schema
  • Fully typed object model and query language

LLBLGen disadvantages:

  • You need the designer application to change your model
  • Not free
  • Can bloat your code because a lot of code is generated

NHibernate advantages:

  • No designer application needed. Only code
  • Widely used (based on the most popular Java ORM, Hibernate)
  • Very powerful for mapping any data model you can imagine
  • Open source

NHibernate disadvantages:

  • Hard to learn
  • Not as strongly typed as one would like (especially queries)

Of course, this is just my personal point of view...

like image 33
Philippe Leybaert Avatar answered Sep 22 '22 22:09

Philippe Leybaert