permaculture playing cards*
The moose likes Object Relational Mapping and the fly likes iBatis in Action: Can I persist my POJOs with it? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "iBatis in Action: Can I persist my POJOs with it?" Watch "iBatis in Action: Can I persist my POJOs with it?" New topic
Author

iBatis in Action: Can I persist my POJOs with it?

Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Welcome to JavaRanch Clinton, Brandon and Larry!

Is iBatis an API which allows me to persist my POJOs to a datasource? If so, do you think it's easier to handle than Entity Beans or Hibernate.

What about the DAO pattern, shall I write a iBatis DAO?

Regards,
Darya


SCJP, SCJD, SCWCD, SCBCD
Brandon Goodin
author
Greenhorn

Joined: Nov 08, 2006
Posts: 14
Honestly, I'm not sure what you are asking. But, iBATIS is a tool to interact with a database via a Datasource. iBATIS uses JDBC to pass sql to the database and then translates the returned resultset into Java objects according to the parameters defined by the developer. iBATIS provides caching that can reduce needless hits against the database.


Brandon Goodin<br />Independent Consultant<br /><a href="http://www.silvermindsoftware.com" target="_blank" rel="nofollow">http://www.silvermindsoftware.com</a>
Timothy Toe
Ranch Hand

Joined: Oct 19, 2002
Posts: 156
If so, do you think it's easier to handle than Entity Beans or Hibernate.


From my little experience with iBatis:
- I find that it is definitely "easier", as in less complex, than Entity Beans 2.x. Hibernate is also "easier", than Entity Beans 2.x.
- I find that iBatis is "easier" than Hibernate. Hibernate tries to shield everything about the DB from the OO programmer. This can be frustrating if you like to write SQL and deal with the DB yourself, having more control etc.

For me, iBatis may be the tool that strikes the right balance between OO and DB, giving you much control over DB stuff like SQL and yet free you from doing low-level JDBC coding.

Having said that, it really depends. If you are not familiar with DB/SQL stuff and want to think in terms of OO programming only, then Hibernate may be "easier" to you/may be more suitable for you.

But then, I am still learning iBatis... What I can say is, I like what I see in iBatis so far.
[ December 05, 2006: Message edited by: Timothy Toe ]
Clinton Begin
author
Greenhorn

Joined: Nov 08, 2006
Posts: 21
>> Is iBatis an API which allows me to persist my POJOs to a datasource?

Yes. It supports JavaBeans, primitives, collections (Map), and XML.

>> If so, do you think it's easier to handle than Entity Beans or Hibernate.

Absolutely easier than Entity Beans (but what isn't?). And yes it can be easier than Hibernate depending on what your needs are (see iBATIS vs. Hibernate topics in this forum).

>> What about the DAO pattern, shall I write a iBatis DAO?

Sure, you can. iBATIS did include a DAO framework for the first 4 years of its life. Spring also supports iBATIS with it's DAO features. But I'm a fan of either avoiding the DAO pattern or writing a custom abstraction layer for a project.

Cheers,
Clinton
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Thanks for your answers,

Originally posted by Brandon Goodin:
... iBATIS is a tool to interact with a database via a Datasource. iBATIS uses JDBC to pass sql to the database and then translates the returned resultset into Java objects according to the parameters defined by the developer. iBATIS provides caching that can reduce needless hits against the database.


Where in an J2EE environment does iBatis belongs? After your answer, I have the feeling that iBatis has no realtion to J2EE at all.

Originally posted by Clinton Begin:
... I'm a fan of either avoiding the DAO pattern or writing a custom abstraction layer for a project.

Cheers,
Clinton


Isn't a DAO pattern a pattern that belongs to J2EE or at least is heavily used there? After your answer I feel that iBatis can play a role in J2EE.

How would you persist the following domain model in a J2EE context with iBatis:

Order --> OrderLineItems

Can you give a little example.

Regards,
Darya
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


Where in an J2EE environment does iBatis belongs? After your answer, I have the feeling that iBatis has no realtion to J2EE at all.

It belongs in the data access layer. I'm not sure I fully grasp what you mean by having a "relation to J2EE", but if you are asking can it be used in conjunction with the various J2EE APIs the answer is yes it can.


Isn't a DAO pattern a pattern that belongs to J2EE or at least is heavily used there?

The DAO pattern need not be used exclusively in applications that use J2EE technologies. It is used extensively in Srping for example.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
In J2EE I have Entity Beans I can use for persistence. Hibernate does a similar job in this context. For J2EE I could show what would be necessary to make my domain objects persistent, be it Entity Beans or Hibernate.

With iBatis I have no clue, whether it is thought to be a replacement for above technics or whether its intended for something complete different.

I would have had a problem to use iBatis for persistence when its intention is not that.

Maybe a small example can share some light

Regards,
Darya
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9930
    
159

Maybe a small example can share some light


How about this one:

iBatis PetStore


[My Blog] [JavaRanch Journal]
Clinton Begin
author
Greenhorn

Joined: Nov 08, 2006
Posts: 21
There are a lot of questions and confusion in this thread. I'm not sure where to start, so instead I'll give you somewhere to start.

First: iBATIS can work within a J2EE application, just like Hibernate, JDBC or any other persistance approach can. J2EE isn't a law, it's a guideline.

To aleviate any concern, realize that iBATIS has existed for 4 years and has been through two major releases.

Have a look at some of the press coverage of iBATIS here:

http://opensource.atlassian.com/confluence/oss/display/IBATIS/Articles+and+other+coverage+of+iBATIS

Get an idea of who's using it here:

http://opensource.atlassian.com/confluence/oss/pages/viewpage.action?pageId=25

Read what some of those people had to say here:

http://opensource.atlassian.com/confluence/oss/display/IBATIS/Feedback+and+Experiences

Then move onto the JPetStore application (under Examples heading):

http://ibatis.apache.org/javadownloads.cgi

Then have a look at the documentation (in your choice of 5 languages under Documentation heading):

http://ibatis.apache.org/javadownloads.cgi

All of the above is available from http://ibatis.apache.org

Then if you're totally sold, buy the book: ;-)

http://www.manning.com/begin/

Hope that helps.

Cheers,
Clinton
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Thanks for all the links.

Regards,
Darya
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: iBatis in Action: Can I persist my POJOs with it?
 
Similar Threads
Separate DAO Classes
Unable to view list in drop down menu - JSTL
Is there anyone who uses entity bean in his/her real enterprise project?
Any books on Spring and iBatis?
Why to use Ibatis DAO pattern