cn.easyproject.easycommons.commondao.util.EasyCriteria Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of easycommondao-hibernate4 Show documentation
Show all versions of easycommondao-hibernate4 Show documentation
Java ORM Common DAO(Data Access Object), eliminate the interface and implements of DAO.
package cn.easyproject.easycommons.commondao.util;
import java.util.ArrayList;
import java.util.List;
/**
* 按条件查询抽象父类(可以结合分页PageBean使用)
*
* SysUserCriteria Demo:
*
*
* public class SysUserCriteria extends EasyCriteria implements java.io.Serializable {
* // 1. Criteria field
* private String name;
* private String realName;
* private Integer status; // 0 is ON; 1 is OFF; 2 is REMOVED
*
* // 2. Constructor
* public SysUserCriteria() {
* }
*
* public SysUserCriteria(String name, String realName, Integer status) {
* super();
* this.name = name;
* this.realName = realName;
* this.status = status;
* }
*
* // 3. Condition genertator abstract method implements
* public String getCondition() {
* values.clear(); // **Must clear old values**
* StringBuffer condition = new StringBuffer();
* if (StringUtils.isNotNullAndEmpty(this.getName())) {
* condition.append(" and name like ?");
* values.add("%" + this.getName() + "%");
* }
* if (StringUtils.isNotNullAndEmpty(this.getRealName())) {
* condition.append(" and realName like ?");
* values.add("%" + this.getRealName() + "%");
* }
* if (StringUtils.isNotNullAndEmpty(this.getStatus())) {
* condition.append(" and status=?");
* values.add(this.getStatus());
* }
* return condition.toString();
* }
*
* // 4. Setters&Getters...
*
* }
*
*
* @author Ray
* @author [email protected]
* @author easyproject.cn
* @since 1.0.0
*/
public abstract class EasyCriteria {
protected List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy