1) Spring configuration file:
<Bean id = "sqlmapclient" class = "org. springframework. Orm. ibatis. sqlmapclientfactorybean">
<Property name = "configlocation" value = "CONF/sqlmapconfig. xml"> </property>
<Property name = "datasource" ref = "datasource"> </property>
</Bean>
2) inherit the sqlmapclientdaosupport class from the daoimpl class. And register the sqlmapclient bean to this class.
Public class monitordaoimpl extends sqlmapclientdaosupport implements
Imonitordao {
}
<Bean id = "monitordao"
Class = "com. **. Dao. Monitor. impl. monitordaoimpl" autowire = "byname">
<Property name = "sqlmapclient" ref = "sqlmapclient"> </property>
</Bean>
Sqlmap example:
< Sqlmap Namespace = "Monitor" >
< Select ID = "T_trafficzoneifipapp" Parameterclass = "Java. util. hashmap"
Resultclass = "Object. Monitor. Traffic" >
Select
T1.neid as neid,
T3.zonename as zonename,
T4.name as ifname,
T1.ipaddr as user,
T5.enname as appname,
T1.upbw as upbw,
T1.downbw as downbw,
T1.downpps as downpps,
T1.uppps as uppps,
T1.rampuprate as rampuprate,
T1.session as session,
T1.inserttstamp as timestamp
From (
< Isgreaterthan Property = "Topn" Comparevalue = "0" >
Select * from $ tablename $ limit # topn: integer #
</ Isgreaterthan >
< Islessequal Property = "Topn" Comparevalue = "0" >
$ Tablename $
</ Islessequal >
) T1
Left join hsm_db.t_neinfo T2 on (t1.neid = t2.neid)
Left join hsm_db.t_zoneinfo T3 on (t1.neid = t3.neid and t1.zoneid = t3.zoneid)
Left join hsm_db.t_ifinfo T4 on (t1.neid = t4.neid and t1.ifid = t4.ifid)
Left join hsm_db.t_appinfo T5 on (t1.neid = t5.neid and t1.appid = t5.appid)
< Dynamic Prepend = "Where" >
< Isgreaterthan Prepend = "And" Property = "Neid" Comparevalue = "0" >
Neid = # neid: integer #
</ Isgreaterthan >
< Isnotempty Prepend = "And" Property = "Zonename" >
Zoneid = (select zoneid from hsm_db.t_zone where zonename = # zonename # limit 1)
</ Isnotempty >
< Isnotempty Prepend = "And" Property = "Ifname" >
Ifid = (select ifid from hsm_db.t_ifinfo where name = # ifname # And neid = # neid # limit 1)
</ Isnotempty >
< Isnotempty Prepend = "And" Property = "User" >
Ipaddr = # user #
</ Isnotempty >
< Isnotempty Prepend = "And" Property = "Appname" >
Appid = # appname #
</ Isnotempty >
< Isnotempty Prepend = "And" Property = "Begintime" >
Inserttstamp <! [CDATA [ > = ]> # Begintime: Timestamp #
</ Isnotempty >
< Isnotempty Prepend = "And" Property = "Endtime" >
Inserttstamp <! [CDATA [ <= ]> # Endtime: Timestamp #
</ Isnotempty >
</ Dynamic >
< Isnotempty Property = "Orderby" >
Order by # orderby #
</ Isnotempty >
< Isgreaterthan Property = "Topn" Comparevalue = "0" >
Limit # topn: integer #
</ Isgreaterthan >
</ Select >
</ Sqlmap >