net.ymate.platform.persistence.mongodb.IMongoQuery Maven / Gradle / Ivy
/*
* Copyright 2007-2107 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.ymate.platform.persistence.mongodb;
import java.util.List;
import net.ymate.platform.persistence.base.OperatorException;
import net.ymate.platform.persistence.mongodb.MongoDB.OrderBy;
import net.ymate.platform.persistence.support.PageResultSet;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
/**
*
* IMongoQuery
*
*
* MongoDB复杂条件查询接口定义;
*
*
* @author 刘镇([email protected])
* @version 0.0.0
*
*
* 版本号 动作 修改人 修改时间
*
*
*
* 0.0.0
* 创建类
* 刘镇
* 2014年2月6日下午5:42:40
*
*
*/
public interface IMongoQuery {
/**
* @return 获取当前使用的数据库连接对象
*/
public IMongoClientHolder getClientHolder();
/**
* @return 获取当前使用的集合对象
*/
public DBCollection getCollection();
/**
* @return 获取当前使用的集合名称
*/
public String getCollectionName();
/**
* 设置结果集数据处理对象
*
* @param handler
*/
public void setResultSetHandler(IMongoResultSetHandler handler);
/**
* @return 当前数据库连接是否可用
*/
public boolean isClientHolderAvailable();
/**
* @return 当前结果集是否可用,即是否为空或元素数量为 0
*/
public boolean isResultSetAvailable();
/**
* @return 获取当前的结果集,若当前操作者对象尚未被执行将抛出运行时异常
*/
public PageResultSet getResultSet();
/**
* @return 是否已执行过操作
*/
public boolean isExecuted();
/**
* 执行查询操作
*
* @return
* @throws OperatorException
*/
public IMongoQuery executeQuery() throws OperatorException;
/**
* 采用分页方式执行查询操作
*
* @param pageNumber
* @param pageSize
* @return
* @throws OperatorException
*/
public IMongoQuery executeQuery(int pageNumber, int pageSize) throws OperatorException;
/**
* @return 返回符合查询条件的记录数
*/
public long executeCount();
public List> executeDistinct(String key);
/**
* @return 将查询条件转换为DBObject对象
*/
public DBObject toDBObject();
//
/**
* 条件:等于
*
* @param key
* @param value
* @return
*/
public IMongoQuery eq(String key, Object value);
/**
* 条件:不等于
*
* @param key
* @param value
* @return
*/
public IMongoQuery notEq(String key, Object value);
/**
* 条件:或
*
* @param querys 子查询集合
* @return
*/
public IMongoQuery or(IMongoQuery>...querys);
/**
* 条件:与
*
* @param querys 子查询集合
* @return
*/
public IMongoQuery and(IMongoQuery>...querys);
/**
* 条件:大于
*
* @param key
* @param value
* @return
*/
public IMongoQuery greaterThan(String key, Object value);
/**
* 条件:大于等于
*
* @param key
* @param value
* @return
*/
public IMongoQuery greaterThanEq(String key, Object value);
/**
* 条件:小于
*
* @param key
* @param value
* @return
*/
public IMongoQuery lessThan(String key, Object value);
/**
* 条件:小于等于
*
* @param key
* @param value
* @return
*/
public IMongoQuery lessThanEq(String key, Object value);
/**
* 条件:包含
*
* @param key
* @param values
* @return
*/
public IMongoQuery in(String key, List