Hibernate vs MyBatis

15 May 2013 | java, ORM, hibernate, myBatis

Comparison of MyBatis versus Hibernate

I’ve often heard people arguing about whether Hibernate is better or MyBatis. The truth is, “there is no spoon.” It is not about whether Hibernate is better or MyBatis, but which of these tools best fits your situation. Without further ado, here is a comparison.

*Disclaimer: This is my personal (and humble) opinion. Some databases were irremediably harmed in the forming of these views.*

MyBatis

It is primarily a data mapper with a database-centric view of things. You map result sets to objects without giving a rat’s rear-end about whether that data came from single/multiple tables, stored procs etc.

Pros:

Cons:

When to Use:

Hibernate

This is primarily an Object-Relational Mapper with an object-centric view of the world. In other words, it maps your object model to database tables with relatively little effort from your side (if the object model is in sync with data model).

Pros:

Cons:

When To Use:

comments powered by Disqus

Older · View Archive (17)

Why ORM?

Why use ORM?

The path to coding Nirvana is a long one. As you navigate these treacherous ways, you’ll find many corpses – of people who have died of SQL over-injection or of Object-Relational-Miscarriage. For those of you who’ve been doing object-relational stuff long enough and have scars in unmentionable places, go back to your drinks. For the rest of you, for whom ‘Why ORM?’ is an interview question, gather around and warm your toes by the electric light.

Newer

The Diary of an AAPtard

Wednesday, 16th April 2014

Tomorrow’s voting day. Have my shiny new voters card. Now just have to vote, to make a difference. Haven’t figured out whom to vote for. Almost all parties are saying the same thing - “Vote for Change”. I’ll vote for change. I’m sick and tired of… of what really? Umm…corruption. Yeah, I’m sick of corruption. That’s what I am sick of. The corrupt traffic cop who fined me 500 bucks for drunk driving and didn’t pay it to the govt. The neighbourhood street cleaner who took extra money to clean up just because I dumped a load of broken glass on the street outside - what am I supposed to do? Wait for the BBMP truck and go to work a little late? Too bloody inconvenient.