Spring and iBatis: Some Notes [Will be updated later] #Java Short Notes

Implementing the data access layer of a Spring application using iBATIS.
Spring Framework and IBATIS

You can use JDBC with Spring for sure. Spring also simplifies the use of JDBC. iBATIS can provide one more step in simplification. Using iBATIS, you can mapdata and Java objects, also make use of simplified database operations.

Using iBatis with Spring involves three steps
Configuration: Configure various files at Data layer to be able to use iBatis
Mapping files: The mapping of the selected rows to the properties of the domain objects.
CRUD Operations: Learn how to use iBatis for select, delete, and update operations.

iBatis Notes:
allows the developer to write the custom SQL code they need to populate the bean properties
In a Spring iBATIS application, you need to configure the reference file and the mapping files.
org.springframework.orm.ibatis.SqlMapClientFactoryBean takes care of loading the configuration files.
You should not create and manage database transactions manually in the iBATIS mapping files. Always delegate the transaction management to Spring
In reference configuration file, you can list the sqlmap files.
You also need to use spring context file (applicationContext.xml ) that will link all configuration file together
it is a good idea to create a separate sqlMap file for each domain object.
Domain objects are POJOs
Mapping files for domains:

                                                         select * from Test     

Configuring iBATIS and Spring
Define the TestDao interface for example and its iBATIS implementation and then add the familiar dataSource bean.
Use the applicationContext.xml file to link the beans together.

usage in a sample application:
context = new ClassPathXmlApplicationContext("applicationContext.xml");
TestDao testDao = (TestDao)context.getBean("testDao");

Use select operation:
Add methods in the DAo as follows:
public List getAll() {
return getSqlMapClientTemplate().queryForList("getAllTests", null);
}

From: http://sitestree.com/?p=5154
Categories:Java Short Notes
Tags:
Post Data:2012-08-13 08:19:19

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

Permanent link to this article: http://bangla.sitestree.com/spring-and-ibatis-some-notes-will-be-updated-later-java-short-notes/

Leave a Reply