- 新增加方法
统计总数没什么特别的,就是一条普通的查询SQL语句
@Select(" select count(*) from category_ ") public int count();
package com.how2java.mapper; import java.util.List; import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; import com.how2java.pojo.Category; public interface CategoryMapper { @Insert(" insert into category_ ( name ) values (#{name}) ") public int add(Category category); @Delete(" delete from category_ where id= #{id} ") public void delete(int id); @Select("select * from category_ where id= #{id} ") public Category get(int id); @Update("update category_ set name=#{name} where id=#{id} ") public int update(Category category); @Select(" select * from category_ ") public List<Category> list(); @Select(" select count(*) from category_ ") public int count(); }
- 测试
Mybatis其他-查询总数
最新推荐文章于 2023-09-14 15:34:18 发布