Use spring-ibatis

Source: Internet
Author: User

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 >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.