Java 返回带有myBatis的ResultMap中的行总数

Java 返回带有myBatis的ResultMap中的行总数,java,select,mybatis,Java,Select,Mybatis,我为这个扩展的ResultMap创建了另外两个字段rowNumber和totalRows。是的,现在我有了总行数,但它存储在结果映射中的每个对象中 <resultMap id="BaseResultMapPagination" type="com.example.emaildto.EmailScheduleDTO" extends="BaseResultMap"> <result property="rowNumber" column="row_number"/>

我为这个扩展的ResultMap创建了另外两个字段rowNumber和totalRows。是的,现在我有了总行数,但它存储在结果映射中的每个对象中

<resultMap id="BaseResultMapPagination" type="com.example.emaildto.EmailScheduleDTO" extends="BaseResultMap">
  <result property="rowNumber" column="row_number"/>
  <result property="totalRows" column="total_count"/>
</resultMap>
<select id="selectByExamplePagination" resultMap="BaseResultMapPagination" parameterType="com.example.emailservice.model.EmailScheduleCriteria">
WITH t as (
    select row_number() OVER(<include refid="orderByPagination"/>) as row_number, 
    count(*) OVER () as total_count,
    * from EmailSchedule t
     <if test="_parameter != null" >
         <include refid="Example_Where_Clause" />
     </if>
)
select * from t where row_number &gt;= #{pageInfo.startRow} AND row_number &lt; #{pageInfo.endRow}
order by row_number ASC
</select>

我怎样才能避开这个问题?

不,不是在同一个查询中。正在为SELECT语句返回的每条记录的每个条目添加两列,因为这是它返回的内容。为了获得返回的总行数,您可以启动第二个查询或获取返回的集合的大小