Print This Post

Aug
13

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 Bookmark on Delicious Digg this post Recommend on Facebook share via Reddit Share with Stumblers Tweet about it Subscribe to the comments on this post Print for later Bookmark in Browser Tell a friend

Print This Post

Aug
09

IBatis vs Hibernate ? Which one to choose?

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… Continue reading »

Print This Post

Aug
08

IBatis Tutorial – Sample Application Step 1

Steps : 1) Creata a databas and a table 2) Create a package com.Employee 3) SQL mapper – Employee.xml Bookmark on Delicious Digg this post Recommend on Facebook share via Reddit Share with Stumblers Tweet about it Subscribe to the comments on this post Print for later Bookmark in Browser Tell a friend

Print This Post

Aug
08

Ibatis Tutorial – Sample Application Step 2

Step 2: Create a package and a java object . package com.Employee import java.io.Serializable; public class Employee implements Serializable { private int employeeID; Bookmark on Delicious Digg this post Recommend on Facebook share via Reddit Share with Stumblers Tweet about it Subscribe to the comments on this post Print for later Bookmark in Browser Tell… Continue reading »

Print This Post

Aug
08

Ibatis Tutorial – Sample Application Step 3

Step 3: Create struts-config.xml <?xml version=”1.0″ encoding=”UTF-8″?> <!DOCTYPE sqlMapConfig PUBLIC “-//ibatis.apache.org//DTD SQL Map Config 2.0//EN” “http://ibatis.apache.org/dtd/sql-map-config-2.dtd”> <sqlMapConfig> <transactionManager type=”JDBC”> <dataSource type=”SIMPLE”> <property name=”JDBC.Driver” value=”com.mysql.jdbc.Driver”/> <property name=”JDBC.ConnectionURL” value=”jdbc:mysql://localhost:3306/employeedb”/> <property name=”JDBC.Username” value=”root”/> <property name=”JDBC.Password” value=””/> </dataSource> </transactionManager> <sqlMap resource=”com/Employee.xml”/> </sqlMapConfig> Also Read : IBatis vs Hibernate ? Which one to choose? IBatis Tutorial – Sample Application Step… Continue reading »

Print This Post

Aug
08

IBatis Tutorial – Sample Application Step 4

Create Employee.xml <?xml version=”1.0″ encoding=”UTF-8″ ?> <!DOCTYPE sqlMap PUBLIC “-//ibatis.apache.org//DTD SQL Map 2.0//EN” “http://ibatis.apache.org/dtd/sql-map-2.dtd”> <sqlMap> <select id=“getEmployee” parameterClass=“int” resultClass=“com.Contact”> SELECT employeeID as employeeID, firstName as firstName, lastName as lastName, email as email from Employee where employeeID=#value# </select> <select id=“getEmployees” resultClass=“com.Employee”> SELECT employeeID as employeeID, firstName as firstName, lastName as lastName, email as email from Employee… Continue reading »

Print This Post

Aug
08

Ibatis Tutorial – Sample Application Step 5

Step 5 : Create a standalone java class to run the application . 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… Continue reading »

Print This Post

Aug
08

IBatis Tutorial Part 3 – SQLMapConfig.xml optional settings

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 : Bookmark on Delicious Digg this post Recommend on Facebook share via Reddit Share with Stumblers Tweet… Continue reading »

Print This Post

Aug
08

Introduction to IBatis Tutorial -Part 1

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… Continue reading »