spring与ibatis结合
1: sql-map-config.xml? 中配置
?
<sqlMapConfig>
?<properties resource="db-dialect.properties" />
?<settings cacheModelsEnabled="true" enhancementEnabled="true"
??lazyLoadingEnabled="false" errorTracingEnabled="true" maxRequests="32"
??maxSessions="10" maxTransactions="5" useStatementNamespaces="true" />
??? <sqlMap resource="com/nstc/sql/${dialect}/HRInterface.xml" />
???
</sqlMapConfig>
?
(说明:db-dialect.properties 为编译后在classes目录下的文件,文件内容:dialect=oracle,目的:可配置性)
?
2:基类?? BaseDao
?
public class BaseDao extends SqlMapClientDaoSupport{
???
}
?
3:applicationContext.xml中如下配置
?
?<bean id="propertyConfigurer"
??????? />
??? </property>?
? </bean>
?
? <bean id="baseDao"
??????? />
??? </property>
?
<bean? id="hrDao"? parent="baseDao"></bean〉
?
?
4:在hrdao中使用
?
public class HRInterfaceDao extends BaseDao {
?
?public? String? getHRMessage(String vcEmployeeID){
??
??Integer?? count = (Integer)this.getSqlMapClientTemplate().queryForObject
?
? ("HRInter.getHRMessage",vcEmployeeID);
????
???? return? count+"";
?}
?
?public? void?? updateHRMessage(EmpMessageInfo? empMessageInfo){
??
??this.getSqlMapClientTemplate().update("HRInter.updateHRMessage",empMessageInfo);
?}
?
?public? void?? insertHRMessage(EmpMessageInfo? empMessageInfo){
??
??this.getSqlMapClientTemplate().insert("HRInter.insertHRMessage",empMessageInfo);
??
?}
?
?
?
}