Monday, June 30, 2008

iBATIS Training - Day 2

Abstract factory Design Pattern

This provides an interface for creating Objects ( or families of related or dependent Objects) without specifying the concrete class for implementation

Aspect Oriented Programming(AOP) is based on Decorative Design Pattern and Strategy Design Pattern

CLASSIC Example of Singelton Design Pattern is Use of ApplicationResource.properties in Struts Framework.

At DAO Layer, Spring provides many templates like
1. Jdbc Template - By EXTENDING this SpringJDBC Integration is done
2. Sql Template - By EXTENDING this SpringiBATIS Integration is done
3. Hibernate Temmplate - By EXTENDING this SpringHibernate Integration is done


Steps for integrating Struts with Spring
1. Define applicatiobnContext.xml
2. In Web.xml sprcify the context path
3. Specify the servlet,context parameter and the listener

* Listeners in the Web.xml are loaded at the Startup of Server

Friday, June 27, 2008

iBATIS

Framework - Some of the common things found in all j2ee frameworks like iBATIS, spring, struts and others are
a. Builtin Classes
b. Configuration Files

iBATIS is Persistance layer framework which has Data Mapping


iBATIS supports inline SQL statements, dynamic SQL statements, ORM (Object Relational Framework). Even HIBERNATE is an ORM framework.

In HIBERBATE, Java Class and Database Table Mapping is done.

iBATIS supports SQL. We can write pseudo SQL statements in sql-map-config.xml

** iBATIS supports Aggregation with the help of ResultMap

For E.g

Class UserDetails{

String address;
String contact
}


Class User
{
String userId;
String passwd;
UserDetails userDetails;

}

Insertions,Updations of User Object is handled in a normal way.

For Retrieving User
UserDetails.xml would contain normal

For User.xml





LazyLoading Feature in iBATIS

Suppose if there are 1000 Master records and 1000 Detail records for each Master AND say we need to display a Detail Record on selection of given Master Record...

By implementing Lazy Loading DetailsRecord is fetched only once Master Record id selected.

RowHandler concept is similar to this.. What is the exact difference ?


Using #value# in<> for inline sql is sql injection PROOF.. where as $value is not



mainly 2 Types of Transactions

1. Flat Transaction - If there are 5 events in a transaction and one of them fails, all others are ROLLED BACK

2. Nested Transaction - If one of the 5 events fails, it is not ROLLED BACK. Here events are ordered in TREE fashion


Different Transaction Managers in iBATIS

1 JDBC - Transactions will be managed by JDBC

2 JTA - App Server Transaction Management details are used

3 EXTERNAL - Your Own Transaction Manager