iBATIS vs. Hibernate Following are some of the differences between the two. 1) Hibernate works well when you control the data model, iBATIS works well when you need to integrate with an existing database. 2) Hibernate is magic, Hibernate is fascinating. The benefits of Hibernate are that it

shopholisticΛογισμικό & κατασκευή λογ/κού

13 Δεκ 2013 (πριν από 3 χρόνια και 6 μήνες)

78 εμφανίσεις

iBATIS vs. Hibernate


Following are some of the differences between the two.


1)
Hibernate works well when you control the data model, iBATIS works well when you
need to integrate with an existing database.


2)

Hibernate is magic, Hibernate is fascinating
.

The benefits of Hibernate are that it

automatically generates all the SQL for your and the cache invalidation

can be more fine
grained. iBATIS is more
simple and
flexible especially if you are

a strong SQL query
writer. You have control over exactly ho
w the SQL

queries are written.


3)

Moreover,

one do
es no
t need abstraction when the
environment

is well defined.
That
is
, when the
environment

can change (the database for Hibernate/the browser for jsf)
these are good abstraction levels, but it

is not

wort
h in 85% of the projects
.

Ibatis can
have better performance and less pain when you try to integrate existing database.


4)
iBATIS maps Java Objects to the results of SQL Queries, whereas

Hibernate maps
Java Objects directly to database tables, traditiona
l

Object
-
Relational Mapping.


5
)
When determining which framework to use, I think one thing to remember

i
s that there
is an optimal relational model to support every object

model. There is not an optimal
object model to represent every

relational model.

Use H
ibernate if you have mostly
s
tandard

queries (
CRUD, Find by Criteria, etc.) and if you are designing your

object
model first, then a relational model to support the object model.

If you are working with a
legacy system or a schema designed by a DBA,

iBATIS often makes a better
c
hoice. If
you try to shoehorn hibernate

into a relational model created by a DBA who could care
less about

objects and thinks in terms of tables, columns, relationships and record

sets,
then you will get along better with your

DBA if you use iBATIS,

especially if the model
is complex and may entail queries with outer

joins and nested
sub queries
. You can tell
them "All of the SQL

statements used by my application are stored in these XML files
outside

of my Java code, so you ca
n easily review them". DBAs like that. Of


course,
you might be lucky enough to work with a DBA that is
familiar
with OO design and
ORM tools like hibernate, in which case hibernate

might make a better choice.


Bottom line, compared to Hibernate, iBATIS
is more

flexible, has a shorter learning
curve, but can take more time to

develop and maintain, since you have to write all your
queries and if

your object model changes you have to go through all your
q
ueries and

make sure to make all the necessary change
s to reflect the changes in

your object model
.