Return to the practice similar to select *from
Process:
CREATE PROCEDURE SelectAll ()
BEGIN
select * from user;
End
XML configuration:
<select id= "SelectAll" resulttype= "map" statementtype= "callable" >
{Call SelectAll ()}
</select>
Java configuration:
Service Layer Invocation
list<map<string, object>> ss = Accountmapper.selectall ();
DAO calls
Public list<map<string,object>> SelectAll ();
SQL code
-- --------------------------------------------------------------------------------
--Routine DDL
--note:comments before and after the routine body is not being stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$
CREATE definer= ' root ' @ ' localhost ' PROCEDURE ' selectcount ' (
in Pcsid int,
in Drid int,
in Partnerid int,
in CustomerId int,
Out Pcscount int,
Out Drcount int
)
BEGIN
Select COUNT (md.id) to @pcsC from Mdm_device MD
Left join mdm_device_security mds on mds.device_id = Md.id
where mds.device_rooted = Pcsid
and md.partner_id = Partnerid and md.customer_id = customerId;
Set pcscount = @pcsC;
Select COUNT (md.id) to @drC from Mdm_device MD
where md.managed_status = Drid and Date_sub (Curdate (), INTERVAL 7 day) <= DATE (md.un_manage_date)
and md.partner_id = Partnerid and md.customer_id = customerId;
Set drcount = @drC;
END
1.java call incoming map. Get via map.
1.1 Mapper File notation
XML code
<parametermap type= "Map" id= "Homevo" >
<parameter property= "Pcsid" jdbctype= "INTEGER" mode= "in"/>
<parameter property= "Drid" jdbctype= "INTEGER" mode= "in"/>
<parameter property= "Partnerid" jdbctype= "INTEGER" mode= "in"/>
<parameter property= "CustomerId" jdbctype= "INTEGER" mode= "in"/>
<parameter property= "Pcscount" jdbctype= "INTEGER" mode= "Out"/>
<parameter property= "Drcount" jdbctype= "INTEGER" mode= "Out"/>
</parameterMap>
<select id= "Selectforhome" parametermap= "Homevo"
Statementtype= "Callable" >
{Call SelectCount (
?,?,?,?,?,?
)}
</select>
1.2 Java call notation
Java code
@Override
Public Stringselecthomecount (Homevo home) throws Exception {
map<string, object> map = new hashmap<string, object> ();
Map.put ("Pscid", 0);
Map.put ("Drid", 1);
Map.put ("Partnerid", 25);
Map.put ("CustomerId", 50);
Map.put ("Isolation", 1);
SelectOne ("Mapper.selectforhome", map);
System.out.println (Map.get ("Pcscount"));
Return Map.get ("Drcount");
}
MyBatis calling the MySQL stored procedure