当前位置:编程学习 > html/css >>

Mybatis 分页查询

[html] 
<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> 

 <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

[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; 
    } 
 

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() {补充:web前端 , HTML/CSS ,

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,