GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  J2EE  >  Hibernate
Go To First  |  Previous Question  |  Next Question 
 Hibernate  |  Question 31 of 33    Print  
What is different between Hibernate and iBatis?

  
Total Answers and Comments: 3 Last Update: January 23, 2009     Asked by: siva2baba 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: dhandabani.j
 

These are the few questions that continuously get asked in most of forums.

What’s really difference between two and really more importantly when should I use one over the other. Its pretty interesting question because there are major differences between iBatis and Hibernate.

Within in the java persistence there is no one size, fits all solution. So, in this case Hibernate which is a de facto standard is used in lot of places.

Let us consider a scenario where Hibernate work great for initial model. Now Suddenly if you are using stored procedures, well we can do it in Hibernate but its little difficult; ok we map those, all of sudden we got some reporting type of queries, those don’t have keys have group bys; with some difficulty here we can use name queries and stuff like that, but now starts getting more complicated, we have complex joins, yes you can do in hibernate, but we can’t do with average developer. We have SQL that just doesn’t work.

So these are some of the complexities. One of the other things I find is, if am looking at an application that does not work very well with an ORM, aside from these considerations of using stored procedures, already using SQL, complex joins. In other words, Hibernate works very well if your data model is well in sync with object model, because ORM solutions like Hibernate map object to tables. However, let’s suppose data model is not in sync with object model, in this case you have do lot of additional coding and complexities are entering into your application, start coming the beyond the benefits of ORM. So, again all of sudden you are noticing that the flow is gone; our application is becoming very very complex and developers can’t maintain the code.

This is where the model starts breaking down. One size does not fit all. So this is where I like to use iBatis; as the alternative solution for these type of situations, iBatis maps results sets to objects, so no need to care about table structures. This works very well for stored procedures, works very well for reporting applications, etc,.

Now the question is , does it work well for simple CRUD applications? Well, it works because what we have to write is sql. Then why not use Hibernate for that?

You can start see Some of the decision criteria that comes into play. So one of the other follow on questions that typically get is , can I use both? That’s really interesting question! because the answer is sure.

But, such a thing will never ever exists is java persistence world. However we can kind of use both to create this little hybrid. So think of this kind scenario, we have very large application where Hibernate is working very well for it, but we have a reporting piece that just is a real nag , its query only , so we can do is, we can use iBatis to pull up the queries for reporting piece and still use Hibernate for all the operational stuff and updates. This model actually works well, it doesn’t break the transactional model, and it doesn’t affect any of the primary & secondary caches with a Hibernate. It’s a good solution.

Use iBatis if

  • You want to create your own SQL's and are willing to maintain them
  • your environment is driven by relational data model
  • you have to work existing and complex schema's

Use Hibernate if

  • your environment is driven by object model and wants generates SQL automatically

The message is,

  • One size does not fit all the java persistence and the important to know there are other solutions besides the traditional ORMs, and that would be iBatis.
  • Both the solutions work well, given their specific domain.
  • Look for the opportunity where you can use both.


Above answer was rated as good by the following members:
getravi2k, shaileshrit, sanjujava
June 23, 2008 03:25:20   #1  
vdurgesh Member Since: June 2008   Contribution: 1    

RE: What is different between Hibernate and iBatis?

1. Hibernate works well when you control the data model
iBatis works well when you need to intergate with an existing database

2. With IBatis you will get full control on SQL but hibenate deals with relationships of tables.


 
Is this answer useful? Yes | No
August 13, 2008 12:14:54   #2  
alkumar2000 Member Since: August 2008   Contribution: 5    

RE: What is different between Hibernate and iBatis?
Ibatis is something in between Hibernate and JDBC.
Hibernate provides a way to represent database rows as objects so that developers can easily call create update delete methods on them where Ibatis helps developers in mapping SQL queries in the form of XML files these queries can be mapped to a name and parameters can be passed to them. Now these queries can be accesed as Java objects and can be called by passing parameters.

 
Is this answer useful? Yes | No
January 22, 2009 07:00:41   #3  
dhandabani.j Member Since: July 2008   Contribution: 1    

RE: What is different between Hibernate and iBatis?

These are the few questions that continuously get asked in most of forums.


What s really difference between two and really more importantly when should
I use one over the other. Its pretty interesting question because there are
major differences between iBatis and Hibernate.


Within in the java persistence there is no one size fits all solution. So
in this case Hibernate which is a de facto standard is used in lot of places.


Let us consider a scenario where Hibernate work great for initial model. Now
Suddenly if you are using stored procedures well we can do it in Hibernate but
its little difficult; ok we map those all of sudden we got some reporting type
of queries those don t have keys have group bys; with some difficulty here we
can use name queries and stuff like that but now starts getting more
complicated we have complex joins yes you can do in hibernate but we can t do
with average developer. We have SQL that just doesn t work.


So these are some of the complexities. One of the other things I find is if
am looking at an application that does not work very well with an ORM aside
from these considerations of using stored procedures already using SQL complex
joins. In other words Hibernate works very well if your data model is well in
sync with object model because ORM solutions like Hibernate map object to
tables. However let s suppose data model is not in sync with object model in
this case you have do lot of additional coding and complexities are entering
into your application start coming the beyond the benefits of ORM. So again
all of sudden you are noticing that the flow is gone; our application is
becoming very very complex and developers can t maintain the code.


This is where the model starts breaking down. One size does not fit all. So
this is where I like to use iBatis; as the alternative solution for these type
of situations iBatis maps results sets to objects so no need to care about
table structures. This works very well for stored procedures works very well
for reporting applications etc .


Now the question is does it work well for simple CRUD applications? Well
it works because what we have to write is sql. Then why not use Hibernate for
that?


You can start see Some of the decision criteria that comes into play. So one
of the other follow on questions that typically get is can I use both? That s
really interesting question! because the answer is sure.


But such a thing will never ever exists is java persistence world. However
we can kind of use both to create this little hybrid. So think of this kind
scenario we have very large application where Hibernate is working very well
for it but we have a reporting piece that just is a real nag its query only
so we can do is we can use iBatis to pull up the queries for reporting piece
and still use Hibernate for all the operational stuff and updates. This model
actually works well it doesn t break the transactional model and it doesn t
affect any of the primary & secondary caches with a Hibernate. It s a good
solution.


Use iBatis if



  • You want to create your own SQL's and are willing to maintain them

  • your environment is driven by relational data model

  • you have to work existing and complex schema's


Use Hibernate if



  • your environment is driven by object model and wants generates SQL
    automatically


The message is



  • One size does not fit all the java persistence and the important to know
    there are other solutions besides the traditional ORMs and that would be
    iBatis.

  • Both the solutions work well given their specific domain.

  • Look for the opportunity where you can use both.


 
Is this answer useful? Yes | NoAnswer is useful 3   Answer is not useful 0Overall Rating: +3    


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape