Mybatis paging Query

Source: Internet
Author: User

[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>
The XXXXMapper. xml file is as follows:

 

POJO class

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; // 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; // 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

[Java]
Package com. dms. pojo;
 
Public class Page {
Public Page (){
Super ();
}

String rp; // number of lines displayed
String newp; // current page number
String key; // keyword
String fields; // database Field
Int start; // start
Int end; // end
String materielCode; // material code
String materielName; // Item Name
String spec; // specification model

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

Package com. dms. pojo;

Public class Page {
Public Page (){
Super ();
}
 
String rp; // number of lines displayed
String newp; // current page number
String key; // keyword
String fields; // database Field
Int start; // start
Int end; // end
String materielCode; // material code
String materielName; // Item Name
String spec; // specification model
 
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;
}
}


 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.