Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between NHibernate and iBATIS.NET?

I am looking for some up to date information comparing NHibernate and iBATIS.NET. I found some information searching Google, but a good bit of it applies either to the Java versions of these products or is dated.

Some specific things I am interested in:

  • Which is better if you control both the data model and the application?
  • iBATIS is repeatedly called simpler to learn - does this have long-term maintenance consequences (i.e. easy to start, hard to maintain)?
  • Do both make it easy to switch the underlying database vendor?
  • How skilled do your developers need to be with SQL?
  • Any major feature that one has that the other lacks?
  • Is either product more suitable for a particular type of application?

Real world examples of observed benefits and drawbacks are appreciated!

EDIT: Thanks for the information. I am doing my own evaluation as well. One thing I am wondering about still, does iBATIS help you to save/update complex object graphs? It seems like NHibernate is nice in that I can pass it a root object and it figures out the details of what, if anything, needs to be updated in the database.

like image 928
Jeremy Avatar asked Mar 29 '09 12:03

Jeremy


2 Answers

I made some research a while ago.

One specific question from me, might give you some additional information: Would you use NHibernate for a project with a legacy database, which is partly out of your control?

Some of your points of interest I can answer:

  • Which is better if you control both the data model and the application?

I can answer it the other way around: If you don't have control over the data model and thus facing some legacy database, iBatis is the better choice.

  • iBATIS is repeatedly called simpler to learn - does this have long-term maintenance consequences (i.e. easy to start, hard to maintain)?

It depends what you want to do with it. If you have a domain driven development approach then iBatis might get painful by time. If you just do simple data manipulation and don't have a full blown domain model then nHibernate might be a overkill by the time.

  • Do both make it easy to switch the underlying database vendor?

Both have mechanisms to shield you off from a specific database vendor, but I admit that have not done intense research in this direction.

  • How skilled do your developers need to be with SQL?

When you use iBatis, you need more SQL skills than NHibernate. Using iBatis you always need to code some SQL. NHibernate doesn't require you to code SQL statements -- it even can do the DDLs for you. Powerful features will require you to go to old good SQL, which will be inevitable.

Some other points:

  • I personally find that iBatis much more lightweighter. You can get things done very quickly. NHibernate is more powerful, but has much more features, which you can use in wrong way.

  • It is possible to combine the use of NHibernate and iBatis! You can use NHibernate for your business logic. For reporting purposes, where you just read data out of tables, fallback to iBatis.

  • If your application has a longer life cycle and a lot of business logic, consider NHibernate. It has a lot of feature aiding you in handle business objects.

  • The community around NHibernate is very active and come up with useful tools.

like image 188
Theo Lenndorff Avatar answered Sep 30 '22 01:09

Theo Lenndorff


In a sense it's comparing apples to oranges.

Which is better if you control both the data model and the application?

They both work with normalized databases well, so they are more-or-less equal if you can shape the db. iBatis is better at mapping to legacy databases since it doesn't actually care about the database structure at all. It only cares about the shape of the result set.

.iBATIS is repeatedly called simpler to learn - does this have long-term maintenance consequences (i.e. easy to start, hard to maintain)?

It is much simpler, but that is because it has a much smaller featureset. I don't think it has any ticking timebomb long term maintenance issues.

Do both make it easy to switch the underlying database vendor?

Yes

How skilled do your developers need to be with SQL?

Both require a good knowledge of SQL. With iBatis, you still have to write the sql queries/procs. With NHibernate you have to know how to write NHibernate queries to get effective SQL. Neither are a replacement for SQL knowledge.

Any major feature that one has that the other lacks?

iBatis is a datamapper (a term used on the iBatis site). NHibernate is a full-blown Object Relational Mapper. iBatis is a great way to go if you primarily want something that takes the monotony out of mapping objects to result sets. However, it doesn't go all the way in trying to solve the object/relational mismatch. NHibernate has many more features such as dirty tracking, caching based on identity /identity map, flexible querying, dynamic sql, batching etc... NHibernate is much more dynamic in that it can do many things in one trip to the DB that could take iBatis several trips.

like image 21
Daniel Auger Avatar answered Sep 30 '22 02:09

Daniel Auger