Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of iBATIS configuration Class and Operation Class

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail the example analysis of iBATIS configuration class and operation class. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

Introduction to iBATIS configuration class

IBATIS configuration class 1, SqlMapFactoryBean has three variables configLocation-- configuration file storage address, sqlmap-- read the configuration file, the generated object, sqlMapProperties.

Spring uses the SqlMapFactoryBean class to read ibatis's configuration file and create a sqlmap. IBATIS reads resources from classpath, so make sure the configuration file is on top of classpath.

* cases:

< bean id= "sqlMap" class= "org.springframework.orm.ibatis.SqlMapFactoryBean" > < property name= "configLocation" > < value > classpath:/sql-map-config.xml < / value > < / property > < / bean >

The sql-map-config.xml file is stored in the src directory.

The second kind of request:

< bean id= "sqlMap" class= "org.springframework.orm.ibatis.SqlMapFactoryBean" > < property name= "configLocation" > < value > WEB-INF/sqlmap-config.xml < / value > < / property > < / bean >

The sql-map-config.xml file is stored in the web-info directory.

Now that sqlmap is defined, you must write a configuration file for iBATIS.

< sql-map-config > < settings statementCacheSize= "0" driverHintsEnabled= "true" / > < sql-map resource= "com/longtop/bas/BasSql.xml" / > < / sql-map-config >

IBATIS configuration class 2, SqlMap object.

Objects generated by xml files are mainly read by SqlMapFactoryBean. There is only one SqlMap object (singleton object) in a project, and SqlMap is equivalent to all ibatis configuration files. Spring invokes SqlMapFactoryBean to generate a SqlMap object and injects the SqlMap object into each SqlDao object (inheriting SqlMapDaoSupport).

Share To

Development

© 2024 shulou.com SLNews company. All rights reserved.

12
Report