DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • SQL Data Manipulation Language (DML) Operations: Insert, Update, Delete
  • How to Build a Full-Stack App With Next.js, Prisma, Postgres, and Fastify
  • How to Store Text in PostgreSQL: Tips, Tricks, and Traps
  • MongoDB to Couchbase for Developers, Part 1: Architecture

Trending

  • Stop Writing Database Migration Scripts: Declarative Schema Sync for Java
  • Spring Security JWT Validation Best Practices
  • Beyond Manual Mapping: AI-Orchestrated Governance for Hybrid Cloud
  • Solving Comprehension Debt in AI-Generated Codebases

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Data Engineering
  3. Databases
  4. Introduction to iBatis (MyBatis), An alternative to Hibernate and JDBC

Introduction to iBatis (MyBatis), An alternative to Hibernate and JDBC

By 
Loiane Groner
·
Feb. 09, 11 · Interview
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
42.8K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

i started to write a new article series about ibatis / mybatis . this is the first article and it will walk you through what is ibatis / mybatis and why you should use it.

for those who does not know ibatis / mybatis yet, it is a persistence framework – an alternative to jdbc and hibernate , available for java and .net platforms. i’ve been working with it for almost two years, and i am enjoying it!

the first thing you may notice in this and following articles about ibatis/mybatis is that i am using both ibatis and mybatis terms. why? until june 2010, ibatis was under apache license and since then, the framework founders decided to move it to google code and they renamed it to mybatis. the framework is still the same though,  it just has a different name now.

i gathered some resources, so i am just going to quote them:

what is mybatis/ibatis?

the mybatis data mapper framework makes it easier to use a relational database with object-oriented applications. mybatis couples objects with stored procedures or sql statements using a xml descriptor. simplicity is the biggest advantage of the mybatis data mapper over object relational mapping tools.to use the mybatis data mapper, you rely on your own objects, xml, and sql. there is little to learn that you don’t already know. with the mybatis data mapper, you have the full power of both sql and stored procedures at your fingertips.
( www.mybatis.org )

ibatis is based on the idea that there is value in relational databases and sql, and that it is a good idea to embrace the industrywide investment in sql. we have experiences whereby the database and even the sql itself have outlived the application source code, and even multiple versions of the source code. in some cases we have seen that an application was rewritten in a different language, but the sql and database remained largely unchanged.

it is for such reasons that ibatis does not attempt to hide sql or avoid sql. it is a persistence layer framework that instead embraces sql by making it easier to work with and easier to integrate into modern object-oriented software. these days, there are rumors that databases and sql threaten our object models, but that does not have to be the case. ibatis can help to ensure that it is not.

( ibatis in action book)

so…

what is ibatis ?

  • a jdbc framework
  • developers write sql, ibatis executes it using jdbc.
  • no more try/catch/finally/try/catch.
  • an sql mapper
  • automatically maps object properties to prepared statement parameters.
  • automatically maps result sets to objects.
  • support for getting rid of n+1 queries.
  • a transaction manager
  • ibatis will provide transaction management for database operations if no other transaction manager is available.
  • ibatis will use external transaction management (spring, ejb cmt, etc.) if available.
  • great integration with spring, but can also be used without spring (the spring folks were early supporters of ibatis).

what isn’t ibatis ?

  • an orm
  • does not generate sql
  • does not have a proprietary query language
  • does not know about object identity
  • does not transparently persist objects
  • does not build an object cache

essentially, ibatis is a very lightweight persistence solution that gives you most of the semantics of an o/r mapping toolkit, without all the drama. in other words ,ibatis strives to ease the development of data-driven applications by abstracting the low-level details involved in database communication (loading a database driver, obtaining and managing connections, managing transaction semantics, etc.), as well as providing higher-level orm capabilities (automated and configurable mapping of objects to sql calls, data type conversion management, support for static queries as well as dynamic queries based upon an object’s state, mapping of complex joins to complex object graphs, etc.). ibatis simply maps javabeans to sql statements using a very simple xml descriptor. simplicity is the key advantage of ibatis over other frameworks and object relational mapping tools.( http://www.developersbook.com )

who is using ibatis/mybatis?

see the list in this link: http://www.apachebookstore.com/confluence/oss/pages/viewpage.action?pageid=25

i think the biggest case is myspace , with millions of users. very nice!

this was just an introduction, so in next articles i will show how to create an application using ibatis/mybatis – step-by-step.

enjoy! :)

from http://loianegroner.com/2011/02/introduction-to-ibatis-mybatis-an-alternative-to-hibernate-and-jdbc/

MyBatis Database Relational database sql Object (computer science) Hibernate application Framework Data (computing) Query language

Opinions expressed by DZone contributors are their own.

Related

  • SQL Data Manipulation Language (DML) Operations: Insert, Update, Delete
  • How to Build a Full-Stack App With Next.js, Prisma, Postgres, and Fastify
  • How to Store Text in PostgreSQL: Tips, Tricks, and Traps
  • MongoDB to Couchbase for Developers, Part 1: Architecture

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook