Difference in map result set obtained through resultmap and resultclass
Alias ing-> entity class: resultclass
<Select id = "selectall" resultclass = "applog">
Select
ID as ID,
Type as type,
Descr as descr
From app_log
Where id = # ID #
</SELECT>
List list = sqlmapper. queryforlist ("selectall ");
For (INT I = 0; I <list. Size (); I ++ ){
Applog log = (applog) list. Get (I );
// Add your code here;
}
Alias ing-> map class: resultclass
<Select id = "selectall" resultclass = "Java. util. hashmap <string, string>">
Select
ID as ID,
Type as type,
Descr as descr
From app_log
Where id = # ID #
</SELECT>
List list = sqlmapper. queryforlist ("selectall ");
For (INT I = 0; I <list. Size (); I ++ ){
Map map = (MAP) list. Get (I );
String id = (string) map. Get ("ID ");
String type = (string) map. Get ("type ");
String descr = (string) map. Get ("descr ");
// Add your code here;
}
Explicit ing-> entity class: resultmap
<Resultmap id = "applogresult" class = "applog">
<Result property = "ID" column = "ID"/>
<Result property = "type" column = "type"/>
<Result property = "descr" column = "descr"/>
</Resultmap>
<Select id = "selectall" resultmap = "applogresult">
Select * From app_log
</SELECT>
List list = sqlmapper. queryforlist ("selectall ");
For (INT I = 0; I <list. Size (); I ++ ){
Applog log = (applog) list. Get (I );
// Add your code here;
}
Explicit ing-> map class: resultmap
<Resultmap id = "Map-result" class = "Java. util. hashmap">
<Result property = "ID" column = "ID"/>
<Result property = "type" column = "type"/>
<Result property = "descr" column = "descr"/>
</Resultmap>
<Select id = "selectall2" resultmap = "Map-result">
Select * From app_log
</SELECT>
List list = sqlmapper. queryforlist ("selectall2 ");
For (INT I = 0; I <list. Size (); I ++ ){
Map map = (MAP) list. Get (I );
String id = (string) map. Get ("ID ");
String type = (string) map. Get ("type ");
String descr = (string) map. Get ("descr ");
}
No ing
<Select id = "selectall3" resultclass = "Java. util. hashmap">
Select * From app_log
</SELECT>
List list = sqlmapper. queryforlist ("selectall3 ");
For (INT I = 0; I <list. Size (); I ++ ){
Map map = (MAP) list. Get (I );
String id = (string) map. Get ("ID ");
String type = (string) map. Get ("type ");
String descr = (string) map. Get ("descr ");
}
XML
<Select id = "selectxml" parameterclass = "Java. Lang. String" resultclass = "XML" xmlresultname = "log">
Select
ID as ID,
Type as type,
Descr as descr
From app_log
Where id = # ID #
</SELECT>
String o = (string) sqlmapper. queryforobject ("selectxml", ID );
System. Out. println (O );