iBATIS
| Developer(s) | Apache Software Foundation |
|---|---|
| Development status | Inactive (see MyBatis) |
| Written in | Java, .NET and Ruby |
| Operating system | Cross-platform |
| Type | Persistence Framework |
| License | Apache License 2.0 |
| Website | http://ibatis.apache.org |
iBATIS is a persistence framework which automates the mapping between SQL databases and objects in Java, .NET, and Ruby on Rails. In Java, the objects are POJOs (Plain Old Java Objects). The mappings are decoupled from the application logic by packaging the SQL statements in XML configuration files. The result is a significant reduction in the amount of code that a developer needs to access a relational database using lower level APIs like JDBC and ODBC.
Other persistence frameworks such as Hibernate allow the creation of an object model (in Java, say) by the user, and create and maintain the relational database automatically. iBATIS takes the reverse approach: the developer starts with an SQL database and iBATIS automates the creation of the Java objects. Both approaches have advantages, and iBATIS is a good choice when the developer does not have full control over the SQL database schema. For example, an application may need to access an existing SQL database used by other software, or access a new database whose schema is not fully under the application developer's control, such as when a specialized database design team has created the schema and carefully optimized it for high performance.
On May 21, 2010 the development team decided to move from ASF to Google code changing the project name to MyBatis, making new releases there. As a consequence the Apache iBATIS project became inactive and was moved to the Apache Attic in June 2010.
Contents |
[edit] Usage
For example, assume there is a database table PRODUCT (PROD_ID INTEGER, PROD_DESC VARCHAR(64)) and a Java class com.example.Product (id: int, description: String). To read the product record having the key PROD_ID into a new Product POJO, the following mapping is added into an iBATIS XML mapping file:
<select id="getProduct" parameterClass="java.lang.Long" resultClass="com.example.Product">
select PROD_ID as id,
PROD_DESC as description
from PRODUCT
where PROD_ID = #value#
</select>
A new Java Product object can then be retrieved from the database for product number 123 as follows:
Product resultProduct = (Product) sqlMapClient.queryForObject("getProduct", 123);
In the mapping file example, #value# refers to the long integer value passed into the query. If the parameter is a Java object, then values from properties on that object can be inserted into the query using a similar # notation. For example, if the parameter class is a com.example.Product which has a property called id, then #value# can be replaced with #id#. The sqlMapClient object is an instance of class com.ibatis.sqlmap.client.SqlMapClient.
[edit] Availability
The founder of iBATIS has publicly stated his dismay with Java 5, but has continued to release new versions of iBATIS for Java. Versions 2.3.1 and 2.3.2 came out in April 2008, and 2.3.3 in July. Work is also underway on release 3.0.0, whose features are being discussed here.
The framework is currently available in Java, .NET, and Ruby (RBatis) versions. The jBati project is a JavaScript ORM inspired by iBATIS.
The Apache iBator tool is closely related: it connects to your database and uses SQL introspection to generate iBATIS mapping files and Java classes.
[edit] Project Status
Project development is currently inactive as of June 16th 2010, iBATIS has been retired as mentioned on the official site.
On May 19, 2010 iBATIS 3.0 is published and simultaneously the development team decided to continue the development of the framework at Google Code [1] under the new name MyBatis.
[edit] See also
- MyBatis
- Java Persistence API
- Hibernate
- EclipseLink
- Apache Cayenne
- Spring Framework
- pureQuery
- NHydrate
- OpenJPA
- O/R Broker, similar framework for Scala
[edit] References
[edit] Bibliography
- Begin, Clinton; Brandon Goodin, Larry Meadors (January 17, 2007). iBATIS in Action (1st ed.). Manning. pp. 384. ISBN 1932394825.
- Richardson, Chris (January 23, 2006). POJOs In Action (1st ed.). Manning. pp. 456. ISBN 1932394583.