apache iBATIS
Apache iBATIS | |
---|---|
Developer(s) | Apache Software Foundation |
Operating system | Cross-platform |
Type | Persistence Framework |
License | Apache 2.0 licence |
Website | http://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.