Apache iBATIS

Last updated
Apache iBATIS
Developer(s) Apache Software Foundation
Written in Java, .NET, Ruby
Operating system Cross-platform
Type Persistence framework
License Apache License 2.0
Website 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.

Contents

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 a 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 forked the code creating a new project called MyBatis and making new releases there. As a consequence the Apache iBATIS project became inactive and was moved to the Apache Attic in June 2010.

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:

<selectid="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:

ProductresultProduct=(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.

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.

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 its metadata to generate iBATIS mapping files and Java classes.

History

In 2001 a project called iBATIS was started by Clinton Begin. Originally the focus was on the development of cryptographic software solutions. The first product to be released by iBATIS was Secrets, [1] a personal data encryption and signing tool much like PGP. Secrets was written entirely in Java and was released under an open source license.

That year Microsoft published a paper [2] to demonstrate that its recent .NET 1.0 framework was more productive than Java. For that purpose Microsoft built its own version of Sun's Web "Pet Store", a Web project that Sun had used to show Java best practices (Java BluePrints). Microsoft claimed that .NET was 10 times faster and 4 times more productive than Java.

In 2002 Clinton developed an application called JPetStore [3] to demonstrate that Java could be more productive than .NET and could also do so while achieving a better architecture than was used in the Microsoft implementation.

JPetStore 1.0 had a big impact [4] and the database layer that Clinton used attracted the attention of the community. Soon, iBATIS Database Layer 1.0 project started, composed of two components: iBATIS DAO and iBATIS SQL Maps.

iBATIS 2.0 was released in June 2004. [5] It was a complete redesign while keeping the same features. Clinton donated the iBATIS name and code to Apache Software Foundation and the project stayed in the ASF for six years.

Eventually iBATIS DAO was deprecated, considering that better DAO frameworks were available, such as Spring Framework.

On May 19, 2010 iBATIS 3.0 was published and simultaneously the development team decided to continue the development of the framework at Google Code. [6] under a new project called MyBatis.

On June 16, 2010 Apache announced that iBATIS was retired and moved to the Apache Attic.

See also

Related Research Articles

Object database Database management system

An object database is a database management system in which information is represented in the form of objects as used in object-oriented programming. Object databases are different from relational databases which are table-oriented. Object-relational databases are a hybrid of both approaches.

SQL is a domain-specific language used in programming and designed for managing data held in a relational database management system (RDBMS), or for stream processing in a relational data stream management system (RDSMS). It is particularly useful in handling structured data, i.e. data incorporating relations among entities and variables.

Object-relational mapping in computer science is a programming technique for converting data between incompatible type systems using object-oriented programming languages. This creates, in effect, a "virtual object database" that can be used from within the programming language. There are both free and commercial packages available that perform object-relational mapping, although some programmers opt to construct their own ORM tools.

Object-relational database database management system

An object-relational database (ORD), or object-relational database management system (ORDBMS), is a database management system (DBMS) similar to a relational database, but with an object-oriented database model: objects, classes and inheritance are directly supported in database schemas and in the query language. In addition, just as with pure relational systems, it supports extension of the data model with custom data types and methods.

In computer software, a data access object (DAO) is a pattern that provides an abstract interface to some type of database or other persistence mechanism. By mapping application calls to the persistence layer, the DAO provides some specific data operations without exposing details of the database. This isolation supports the single responsibility principle. It separates what data access the application needs, in terms of domain-specific objects and data types, from how these needs can be satisfied with a specific DBMS, database schema, etc..

Hibernate ORM is an object-relational mapping tool for the Java programming language. It provides a framework for mapping an object-oriented domain model to a relational database. Hibernate handles object-relational impedance mismatch problems by replacing direct, persistent database accesses with high-level object handling functions.

ADO.NET is a data access technology from the Microsoft .NET Framework that provides communication between relational and non-relational systems through a common set of components. ADO.NET is a set of computer software components that programmers can use to access data and data services from a database. It is a part of the base class library that is included with the Microsoft .NET Framework. It is commonly used by programmers to access and modify data stored in relational database systems, though it can also access data in non-relational data sources. ADO.NET is sometimes considered an evolution of ActiveX Data Objects (ADO) technology, but was changed so extensively that it can be considered an entirely new product.

Apache Wicket

Apache Wicket, commonly referred to as Wicket, is a component-based web application framework for the Java programming language conceptually similar to JavaServer Faces and Tapestry. It was originally written by Jonathan Locke in April 2004. Version 1.0 was released in June 2005. It graduated into an Apache top-level project in June 2007.

The Java Persistence API (JPA) is a Java application programming interface specification that describes the management of relational data in applications using Java Platform, Standard Edition and Java Platform, Enterprise Edition/Jakarta EE.

Entity Framework (EF) is an open source object-relational mapping (ORM) framework for ADO.NET. It was a part of .NET Framework, but since Entity Framework version 6 it is separated from .NET framework.

Apache Cayenne Open Source Java framework for object relational mapping (ORM), persistence, and caching

Apache Cayenne is an open source persistence framework licensed under the Apache License, providing object-relational mapping (ORM) and remoting services. Cayenne binds one or more database schemas directly to Java objects, managing atomic commit and rollbacks, SQL generation, joins, sequences, and more. With Cayenne's Remote Object Persistence, those Java objects can even be persisted out to clients via Web Services. Or, with native XML serialization, objects can be further persisted to non-Java clients—such as an Ajax-capable browser.

Microsoft SQL Server is a relational database management system developed by Microsoft. As a database server, it is a software product with the primary function of storing and retrieving data as requested by other software applications—which may run either on the same computer or on another computer across a network. Microsoft markets at least a dozen different editions of Microsoft SQL Server, aimed at different audiences and for workloads ranging from small single-machine applications to large Internet-facing applications with many concurrent users.

The Doctrine Project is a set of PHP libraries primarily focused on providing persistence services and related functionality. Its prize projects are an object-relational mapper (ORM) and the database abstraction layer it is built on top of.

Apache Empire-db is a Java library that provides a high level object-oriented API for accessing relational database management systems (RDBMS) through JDBC. Apache Empire-db is open source and provided under the Apache License 2.0 from the Apache Software Foundation.

The following tables compare general and technical information for a number of online analytical processing (OLAP) servers. Please see the individual products articles for further information.

MyBatis is a Java persistence framework that couples objects with stored procedures or SQL statements using an XML descriptor or annotations.

Dapper is an object-relational mapping (ORM) product for the Microsoft .NET platform: it provides a framework for mapping an object-oriented domain model to a traditional relational database. Its purpose is to relieve the developer from a significant portion of relational data persistence-related programming tasks. Dapper is free as open source software that is distributed under dual license, either the Apache License 2.0 or the MIT License.

Apache Attic is a project of Apache Software Foundation to provide process and solutions to make it clear when an Apache project has reached its end-of-life. The Attic project was created in November 2008. Also the retired projects can be retained.

Persist is a Java-based ORM/DAO tool. It provides only the minimal amount of functionalities necessary to map objects or maps from database queries and to statement parameters.

References

  1. iBATIS Secrets
  2. Cat Fight in a Pet Store: J2EE vs. .NET
  3. "JPetStore 1.0" (PDF). Archived from the original (PDF) on 2013-10-21. Retrieved 2013-09-08.
  4. JPetStore 1.0 announcement on TheServerside.com
  5. iBATIS 2.0 announcement
  6. iBATIS Project Team Moving to Google Code

Bibliography