<-! Namesapce: the full path to implement understood class (package name + class name) -> < Mapper namespace = "ab &" > <-! ID: Method Name parameterType: defining parameters Type resultType: Return Value Type. If the return value is List method, written in the generic List resultType because mybatis of jdbc package, data is read row by row -> < SELECT ID = "a selectAll" resultType = "com.zzu.pojo.People" > SELECT from Test * </ SELECT > < SELECT ID = "COUNT" the resultType = "int" > select count(*) from test </select> <select id="_selectAll" resultType="com.zzu.pojo.People"> select id,name,money from test </select> </mapper>
A, selectList ()
1, the return value List <resultType attribute control>
2, the results are applied to the query need to traverse the demand
List<People> list = session.selectList("a.b.selectAll"); for(People p : list) { System.out.println(p.toString()); }
二、selectOne()
1, the return value Object
2, the results are only applicable to the return line of data or variables
int count = session.selectOne("a.b.count"); System.out.println(count);
Three, selectMap ()
1, the return value of the Map
2, need to take a value suitable to the needs of a column data line in the query results
3, Map <key, resultType control>
Map<Object,Object> map = session.selectMap("a.b._selectAll", "name");
System.out.println(map.toString());