Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

iBatis vs hibernate

 
Raj Ohadi
Ranch Hand
Posts: 316
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone point out which one is better ? why some people pick one over the other ?
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
iBATIS is very simple.
Hibernate is much more complex.

If you are a SQL expert and want to write SQL yourself, choose iBATIS.

But if you don't want to write SQL and you prefer more object-oriented query language and have much time to learn OR-mapping concepts and features, choose Hibernate.

iBATIS is so simple, it is just about XML, SQL, and plain-old objects, nothing more than that.

iBATIS is just a data mapper framework it maps fields in RDBMS tables to attributes in objects while Hibernate is an OR-mapping tool it maps objects to relational database.

Sounds similar, but OR-mapping is higher level than data mapping.
[ December 08, 2008: Message edited by: Kengkaj Sathianpantarit ]
 
John Griffin
author
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raj,

Years ago I had to make a decision between the various ORM systems as to which one to implement. At that time rumor had it that EJB3 would use Hibernate as it's basic methodology (I know the politics behind the decision but that doesn't matter now). We were an EJB company so the decision was easy, Hibernate.

I would bet that more than just us made that decision for the same reason.

John G
 
Mads jacobsen
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The main difference between Hibernate and iBatis is that hibernate maps your objects to tables whereas iBatis maps your objects to SQL queries.

You can also consider the fact that even though HQL is great you can do much more with pure SQL, and it might even perform a great deal better with iBatis then Hibernate, as it allows you to take 100% control of the queries executed.
 
Emmanuel Bernard
author
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A few facts on iBatis vs Hibernate:
- you can actually override every single SQL statement Hibernate generates if you want to. So in essence, Hibernate does everything iBatis does. The description syntax is lighter on iBatis but you will probably not want to rewrite all Hibernate queries, so all in all the syntax overhead is probably easily overcome.
- Hibernate is much more than iBatis in the sense that it is a persistence context that guarantees a lot of things including object unicity, transparent object checking, first (and second) object level cache and many more things.

The philosophy is way different in the end. One focuses a lot of pure SQL and simple mapping, while Hibernate does focuses on mapping your domain model and managing object state changes for you whil providing you an object oriented query model (and let you back up to SQL if you need to). Also, no Hibernate has full-text search queries thanks to Hibernate Search
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic