This is where you need to provide all configurations for iBatis. Create an XML file with name SqlMapConfig.xml » Read more: iBatis Tutorial Part 2 – SQLMapConfig.xml Basics
This is where you need to provide all configurations for iBatis. Create an XML file with name SqlMapConfig.xml » Read more: iBatis Tutorial Part 2 – SQLMapConfig.xml Basics
A lot of people ask me when i give sessions on IBatis.Which is better ?IBatis or Hibernate? IBatis maps the Java Objects to the SQL Query’s results. Hibernate, maps Java Objects to DB tables (Object-Relational Mapping). Hibernate automatically generates all the SQL for you. In IBatis you can directly write queried in SQL, thus if you are a good SQL programmer, you would find learning Ibatis very easy. Thus Ibatis allows you to do anything what could be done through SQL. Thus you can virtually know what the affect of a query would be.
Steps :
1) Creata a databas and a table
2) Create a package com.Employee
3) SQL mapper – Employee.xml
» Read more: IBatis Tutorial – Sample Application Step 1
Step 2: Create a package and a java object .
package com.Employee
import java.io.Serializable;
public class Employee implements Serializable {
private int employeeID;
» Read more: Ibatis Tutorial – Sample Application Step 2
<?xml version="1.0" encoding="UTF-8"?>Also Read : IBatis vs Hibernate ? Which one to choose?
IBatis Tutorial – Sample Application Step 4
Introduction to IBatis Tutorial -Part 1
<?xml version="1.0" encoding="UTF-8" ?>Also Read : IBatis vs Hibernate ? Which one to choose?
IBatis Tutorial – Sample Application Step 5
Introduction to IBatis Tutorial -Part 1
import java.io.Reader;
import java.util.List;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import com.model.Employee;
public class QueryEmployee {
public static void main(String[] args) {
try {
String resource = “SqlMapConfig.xml”;

Reader reader = Resources.getResourceAsReader(resource);
SqlMapClient sqlMap =
SqlMapClientBuilder.buildSqlMapClient(reader);
Integer employeePrimaryKey = new Integer(1);
Employee employee =
(Employee)sqlMap.queryForObject(”getEmployee”,
employeePrimaryKey);
System.out.println(employee.getFirstName()
+ “\t” + employee.getLastName());
}catch(Exception e) {
e.printStackTrace();
}
}
}
Also Read : IBatis vs Hibernate ? Which one to choose?
IBatis Tutorial – Sample Application Step 1
Here are some of the options setting which are worth mentioning.
<settings
maxRequests ="120"
maxSessions ="20"
maxTransactions="10"
lazyLoadingEnabled =" true"
enhancementEnabled ="true"
cacheModelsEnabled ="true"
useStatementNamespaces ="false"
defaultStatementTimeout ="5" />
<typaAlias alias = ""employee> type ="com.Emloyee" />
Settings attributes : » Read more: IBatis Tutorial Part 3 – SQLMapConfig.xml optional settings
This is a tutorial on IBatis . 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.
IBatis couples objects with stored procedures or SQL statements using a XML descriptor.iBatis provides a set of APIs which can be used to call these statements written in an XML file. Also since IBatis gives you the power to write any SQL query in the XML file, there is nothing that IBatis cannot achieve, thus making it a very good persistence framework.IBatis is simple to learn and anyone who can write SQL queries can very well work on this. » Read more: Introduction to IBatis Tutorial -Part 1