⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 querycar.java

📁 办公自动化项目
💻 JAVA
字号:
package com.t60.oa.service.car;

import java.util.List;

import com.t60.oa.po.Car;
import com.t60.oa.web.car.QuerycarActionForm;
import hong.javanet.dao.HibernateUtil;
import org.hibernate.Session;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import com.t60.oa.web.car.AddcarActionForm;
public class Querycar
{
    private List result;
    private String message;
    private QuerycarActionForm form;
    private int pageIndex;
    private int pageSize=4;
    private boolean needCount;
    private int pageCount;
    private int rowCount;
    public void querycar()
    {
        Session session=HibernateUtil.currentSession();
        org.hibernate.Criteria crem=session.createCriteria(Car.class);
        AddcarActionForm ac=new AddcarActionForm();
        crem.setProjection(Projections.projectionList() //投影 获得对象数组
                            .add(Projections.property("num"))
                            .add(Projections.property("type"))
                            .add(Projections.property("state"))
                 );
         if (form.getNum() != null && form.getNum().trim().length() > 0) {
             String num = form.getNum().trim();
             crem.add(Restrictions.like("num", "%" + num + "%"));
         }
         if (form.getType() != null && form.getType().trim().length() > 0) {
             String type = form.getType().trim();
             System.out.println(type);
             crem.add(Restrictions.like("type", "%" + type + "%"));
         }
         if (form.getState() != null && form.getState().trim().length() > 0) {
             String state = form.getState().trim();
             System.out.println(state);
             crem.add(Restrictions.like("state", "%" + state + "%"));
         }

         crem.setMaxResults(this.pageSize);
         crem.setFirstResult((this.pageIndex - 1) * this.pageSize);
         this.result = crem.list();
         if (this.needCount)
         {
             crem.setProjection(Projections.rowCount());
             this.rowCount = ((Integer) crem.uniqueResult()).intValue();
             this.pageCount = (this.rowCount - 1) / this.pageSize + 1;
         }
  }

    public QuerycarActionForm getForm() {
        return form;
    }

    public String getMessage() {
        return message;
    }

    public List getResult() {
        return result;
    }

    public boolean isNeedCount() {
        return needCount;
    }

    public int getPageCount() {
        return pageCount;
    }

    public int getPageIndex() {
        return pageIndex;
    }

    public int getPageSize() {
        return pageSize;
    }

    public int getRowCount() {
        return rowCount;
    }

    public void setForm(QuerycarActionForm form) {
        this.form = form;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void setResult(List result) {
        this.result = result;
    }

    public void setNeedCount(boolean needCount) {
        this.needCount = needCount;
    }

    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public void setRowCount(int rowCount) {
        this.rowCount = rowCount;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -