Mybatis 分页查询
Mybatis 分页查询
蜀山下的鱼 发表于3年前
Mybatis 分页查询
  • 发表于 3年前
  • 阅读 109
  • 收藏 1
  • 点赞 0
  • 评论 0

新睿云服务器60天免费使用,快来体验!>>>   

<select id="getAllMateriel" resultType="Materiel" parameterType="Page">
		Select *,(select count(*) from Materiel_Info)as total FROM (
		select ROW_NUMBER()Over(order by MaterielCode desc) as rowId,* from Materiel_Info)
		as mytable
		<where> <if test="start !=null and end !=null">
				rowId between #{start} and #{end}
				</if>
				<if test="materielCode != null and materielCode !=''">
				AND materielCode like '%${materielCode}%'
				</if>
				<if test="materielName !=null and materielCode !=''">
				AND materielName like '%${materielName}%'
				</if>
				<if test="spec !=null and spec !=''">
				AND spec like '%${spec}%'
				</if>
 		</where>
	</select>


XXXXMapper.xml      文件如上

 

POJO类

Materiel.java

package com.dms.pojo;

public class Materiel {

	public Materiel() {
		super();
	}

	String MaterielCode;
	String MaterielName;
	String spec;
	String unit;
	float volume;
	float weight;
	String Note;
	String GroupCode;

	int total;	//总数

	public String getMaterielCode() {
		return MaterielCode;
	}

	public void setMaterielCode(String materielCode) {
		MaterielCode = materielCode;
	}

	public String getMaterielName() {
		return MaterielName;
	}

	public void setMaterielName(String materielName) {
		MaterielName = materielName;
	}

	public String getSpec() {
		return spec;
	}

	public void setSpec(String spec) {
		this.spec = spec;
	}

	public String getUnit() {
		return unit;
	}

	public void setUnit(String unit) {
		this.unit = unit;
	}

	public float getVolume() {
		return volume;
	}

	public void setVolume(float volume) {
		this.volume = volume;
	}

	public float getWeight() {
		return weight;
	}

	public void setWeight(float weight) {
		this.weight = weight;
	}

	public String getNote() {
		return Note;
	}

	public void setNote(String note) {
		Note = note;
	}

	public String getGroupCode() {
		return GroupCode;
	}

	public void setGroupCode(String groupCode) {
		GroupCode = groupCode;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

}


Page.java

package com.dms.pojo;

public class Page {
	public Page(){
		super();
	}
	
	String rp;  //显示条数
	String newp;//当前页码
	String key; //关键字
	String fields;//数据库字段
	int start;   //开始
	int end;     //结束
	String materielCode;//物料编码
	String materielName;//物料名称
	String spec;//规格型号
	
	public String getRp() {
		return rp;
	}

	public void setRp(String rp) {
		this.rp = rp;
	}

	public String getNewp() {
		return newp;
	}

	public void setNewp(String newp) {
		this.newp = newp;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getFields() {
		return fields;
	}

	public void setFields(String fields) {
		this.fields = fields;
	}

	public int getStart() {
		return start;
	}

	public void setStart(int start) {
		this.start = start;
	}

	public int getEnd() {
		return end;
	}

	public void setEnd(int end) {
		this.end = end;
	}

	public String getMaterielCode() {
		return materielCode;
	}

	public void setMaterielCode(String materielCode) {
		this.materielCode = materielCode;
	}

	public String getMaterielName() {
		return materielName;
	}

	public void setMaterielName(String materielName) {
		this.materielName = materielName;
	}

	public String getSpec() {
		return spec;
	}

	public void setSpec(String spec) {
		this.spec = spec;
	}
}


 

  • 打赏
  • 点赞
  • 收藏
  • 分享
共有 人打赏支持
粉丝 9
博文 405
码字总数 0
×
蜀山下的鱼
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: