Jump to content

apache iBATIS

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Modelsides (talk | contribs) at 12:25, 28 June 2007 (Basic idea explanation). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Apache iBATIS
Developer(s)Apache Software Foundation
Operating systemCross-platform
TypePersistence Framework
LicenseApache 2.0 licence
Websitehttp://ibatis.apache.org/

iBATIS is a persistence framework which enables mapping sql queries to POJOs (Plain Old Java Objects). The sql queries are decoupled from an application by putting the queries in XML files. Mapping of the retrieved objects is automatic or semi-automatic.

The basic idea behind the iBATIS introduction was to significatntly reduce the amount of Java code that a Java developernormally need to access a relational database.

For example there may exist a database table PRODUCT (PRD_ID : INTEGER, PRD_DESCRIPTION : VARCHAR) and a Java object com.example.Product (id : int, description : String). To populate the contents of a particular PRODUCT of a specified PRD_ID into the Product POJO we would insert the following into a XML SQL map: -

   <select id=”getProduct” 
parameterClass=”com.example.Product”>
resultClass=”com.example.Product”>
select
PRD_ID as id,
PRD_DESCRIPTION as description
from PRODUCT
where PRD_ID = #id#
</select>

The Java code which sets up a parameter object and populates the result object is as follows: -

   Product paramProduct = new Product ();
   paramProduct.setId (123);
   
   Product resultProduct = IBatis.getObject ("getProduct", paramProduct);

Note the #id# comes from the parameter object.

The framework is currently available in Java, .NET, and Ruby(RBatis) version.

See Also