通常查询数据库返回javabean这样的查询结果时,写查询的语句需要先配置好,如下例:
<resultMap type="demo.entity.AppList" id="resultMap">
<result column="appid" property="appid" jdbcType="VARCHAR" />
<result column="schoolid" property="schoolid" jdbcType="VARCHAR" />
<result column="appname" property="appname" jdbcType="VARCHAR" />
<result column="app_departid" property="app_departid" jdbcType="VARCHAR" />
<result column="apptype" property="apptype" jdbcType="VARCHAR" />
</resultMap>
标签中type属性是指定要输出的javabean,标签中,column对象数据库中的字段名,property对应javabean中的属性名,jdbcType指定该字段的数据类型。
接下来就是几种查询语句的写法:
1. 分页查询
<select id="selectAll" parameterType="int" resultMap="resultMap">