The MySQL stored procedure can directly return the result set with the out parameter.
For example:
Stored Procedure:
Create procedure 'test' <br/> (in _ login varchar (32), <br/> In _ psw varchar (32 ), <br/> out _ ret integer (10), <br/> out _ id INTEGER (10), <br/> out _ name varchar (32 ), <br/> out _ email varchar (32), <br/> out _ phone varchar (20), <br/> out _ active INTEGER (11 )) // multiple result sets are returned simultaneously </P> <p> begin <br/> declare continue handler for not found SET _ ret =-1; <br/> SET _ ret = 0; </P> <p> select ID, name, email, phone, active <br/> I NTO _ id, _ name, _ email, _ phone, _ active <br/> from test <br/> where tx_account. 'loginname' = _ login and tx_account. 'Password' = MD5 (_ psw) and active = 1; <br/> --------- return result set ----- <br/> If _ ret = 0 then <br/> select. ID as ID,. name as name,. priority as priority <br/> from Test B left join test1 A on B. role =. ID <br/> where B. account = _ id; <br/> end if; <br/> end; </P> <p> direct return result set <br/> ibatis file <br/> <paramete RMAP id = "testparametermap" class = "Params"> <br/> <parameter property = "loginname" jdbctype = "varchar" javatype = "Java. lang. string "mode =" in "/> <br/> <parameter property =" password "jdbctype =" varchar "javatype =" Java. lang. string "mode =" in "/> <br/> <parameter property =" RET "jdbctype =" integer "javatype =" Java. lang. integer "mode =" out "/> <br/> <parameter property =" ID "jdbctype =" integer "javatype =" Java. lang. I Nteger "mode =" out "/> <br/> <parameter property =" name "jdbctype =" varchar "javatype =" Java. lang. string "mode =" out "/> <br/> <parameter property =" phone "jdbctype =" varchar "javatype =" Java. lang. string "mode =" out "/> <br/> <parameter property =" email "jdbctype =" varchar "javatype =" Java. lang. string "mode =" out "/> <br/> <parameter property =" active "jdbctype =" integer "javatype =" Java. lang. integer "mode =" out "/> <br /> </Parametermap> </P> <p> <procedure id = "test" parametermap = "testmap" resultmap = "accountroleresultmap"> <br/> {call test (? ,?,?,?,?,?,?,?)} <Br/> </procedure> </P> <p> DAO implementation <br/> defines a map Params for passing parameters, </P> <p> hashmap <string, Object> Params = new hashmap <string, Object> (); <br/> // put the required parameters in Map <br/> Params. put ("ID", account. GETID (); <br/> Params. put ("RET", null); <br/> Params. put ("loginname", null); <br/> Params. put ("name", null); <br/> Params. put ("email", null); <br/> Params. put ("phone", null); <br/> Params. put ("active", null); <br/> // defines a lis T <br/> List list = NULL; <br/> List = (list) (getsqlmapclienttemplate (). queryforlist ("test", Params); <br/> // you can obtain the result set returned by the stored procedure. <Br/> Object var; <br/> Var = Params. Get ("RET"); // obtain the value of the specified output parameter from map. </P> <p>
Declare the returned result set in the configuration file of ibatis that is not required by MySQL.
I have not tried it yet. I don't know if it works. I will try it here first.