Introduction to mybatis
2011-11-09 10:15
162 查看
Introduction to iBatis (MyBatis), An alternative to Hibernate and JDBC
I started to write a new article series aboutiBatis/MyBatis. This is the first article and it will walk you through what isiBatis/MyBatisand
why you should use it.
For those who does not know
iBatis/MyBatis yet, it is a persistence framework – an alternative to JDBC andHibernate, available for Java and .NET platforms. I’ve been working
with it for almost two year, and I am enjoying it!
The fisrt thin you may notice in thisand following articles about iBatis/MyBatis is that I am using iBatisand Mybatis terms. Why? Until June 2010, iBatis was under Apachelicense and since then, the framework founders decided to
move it toGoogle Code and they renamed it to MyBatis. The framework is still thesame though, only has a different name now.
I gathered some resources, so I am just going to quote them:
What is MyBatis/iBatis?
The MyBatis data mapperframework makes it easier to use a relational database withobject-oriented applications. MyBatis couples objects with storedprocedures or SQL statements using a XML descriptor. Simplicity is thebiggest advantage of the MyBatis datamapper over object relationalmapping tools.
To use the MyBatis data mapper, you rely on your own objects, XML, andSQL. There is little to learn that you don’t already know. With theMyBatis Data Mapper, you have the full power of both SQL and storedprocedures at your fingertips.
(www.mybatis.org)
iBATIS is based on the ideathat there is value in relational databases and SQL, and that it is agood idea to embrace the industrywide investment in SQL. We haveexperiences whereby the database and even the SQL itself have outlivedthe application source code,
and even multiple versions of the sourcecode. In some cases we have seen that an application was rewritten in adifferent language, but the SQL and database remained largely unchanged.
It is for such reasons that iBATIS does not attempt to hide SQL oravoid SQL. It is a persistence layer framework that instead embracesSQL by making it easier to work with and easier to integrate intomodern object-oriented software. These days, there are
rumors thatdatabases and SQL threaten our object models, but that does not have tobe 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 thatgives you most of the semantics of an O/R Mapping toolkit, without allthe drama. In other words ,iBATIS strives to ease the development ofdata-driven applications by abstracting the low-level
details involvedin database communication (loading a database driver, obtaining andmanaging connections, managing transaction semantics, etc.), as well asproviding higher-level ORM capabilities (automated and configurablemapping of objects to SQL calls, data
type conversion management,support for static queries as well as dynamic queries based upon anobject’s state, mapping of complex joins to complex object graphs,etc.). iBATIS simply maps JavaBeans to SQL statements using a verysimple XML descriptor. Simplicity
is the key advantage of iBATIS overother 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 isMySpace, 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!
相关文章推荐
- Introduction to MyBatis Generator Mybatis代码生成介绍
- Introduction to Sound Programming with ALSA(2)
- 1 Introduction to Oracle Database读书笔记
- Introduction to discrete event system-学习笔记4.6
- Building a WPF Sudoku Game, Part 1: Introduction to WPF and XAML
- Introduction to C++ Programming in UE4
- An introduction to debugging in MSVC++ using Pseudoregisters(转自codeproject)
- Ex5.1-3 of Introduction to Algorithms
- An Introduction to Programming in Go - v1
- Introduction to Seccomp: BPF linux syscall filter
- Solution for Introduction to Algorithms (3rd Edition) Exercise 26.4-2
- Introduction To Ad-Hoc Commands:
- An Introduction to Language Processing with Perl and Prolog: An Outline of Theories, Implementation,
- Inside OpenSolaris: Introduction to Solaris Drivers
- Introduction to RPC - Part 1
- 转:Simple Introduction to Dirichlet Process
- An introduction to SOLID principles in OO design
- Jena文档《An Introduction to RDF and the Jena RDF API》的译文
- Mybatis报错(二)You have an error in your SQL syntax; check the manual that corresponds to your MySQL se
- A tutorial introduction to git (for version 1.5.1 or newer)