iBATIS in other words is an additional layer of indirection between the classes and the tables allowing it in more flexibility in how classes and tables are mapped with out making any changes to the Data model and the Object model. The layer of indirection here is the SQL.
8. iBatis: Installation iBATISis delivered in a single JAR file: ibatis-version.build.jarand should be copied and made available at runtime via the application's class path. This can be downloaded from iBatis homepage. Get to know iBatis from Rohit @ http://rohitprabhakar.com
16. Spring-iBatis Integration SqlMapConfig.xml As for the configLocation property, it should be configured with the path to an XML file that enumerates the locations of the iBATIS SQL maps. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL MAP Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd"> <sqlMapConfig> <settings useStatementNamespaces="true" /> <sqlMap resource="StudentSQLMap.xml" /> </sqlMapConfig> Get to know iBatis from Rohit @ http://rohitprabhakar.com
18. Spring-iBatis Integration Create an Interface StudentService package com.test.ibatis; public interface StudentService { public Student getStudent(long studentId) throws Exception; } Get to know iBatis from Rohit @ http://rohitprabhakar.com
19. Spring-iBatis Integration Create an Implementation Class package com.test.ibatis; import com.ibatis.sqlmap.client.SqlMapClient; public class StudentServiceImpl implements StudentService { protected SqlMapClientsqlMapclient=null; public void setSqlMapclient(SqlMapClientsqlMapclient) { this.sqlMapclient = sqlMapclient; } public Student getStudent(long studentId) throws Exception { return (Student) sqlMapclient.queryForObject("student.getStudent", studentId); } } Get to know iBatis from Rohit @ http://rohitprabhakar.com
20. Spring-iBatis Integration: Student Client package com.test.ibatis; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class StudentClient { public static void Main(String[] args) { // load spring beans ApplicationContextctx= new ClassPathXmlApplicationContext("applicationContext.xml"); StudentServicestudentService= (StudentService) ctx.getBean("studentService"); //get Object Student intstudentId=1; try { System.out.println("**********************************"); System.out.println(studentService.getStudent(studentId)); System.out.println("**********************************"); } catch (Exception e) {e.printStackTrace();} } } Get to know iBatis from Rohit @ http://rohitprabhakar.com
22. iBatis: Tools Ibator Ibator is a code generator and Eclipse plugin. It can be used to get a head start on your project by generating your Beans, Mappings and SQL from an existing database schema. Get to know iBatis from Rohit @ http://rohitprabhakar.com