
net.ymate.platform.persistence.mongodb.IMongoSession Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ymate-platform-persistence-mongodb
Show all versions of ymate-platform-persistence-mongodb
YMP Persistence for MongoDB.
/*
* Copyright 2007-2017 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 com.mongodb.client.AggregateIterable;
import com.mongodb.client.DistinctIterable;
import com.mongodb.client.MapReduceIterable;
import net.ymate.platform.persistence.*;
import net.ymate.platform.persistence.base.IEntity;
import net.ymate.platform.persistence.mongodb.support.Aggregation;
import net.ymate.platform.persistence.mongodb.support.OrderBy;
import net.ymate.platform.persistence.mongodb.support.Query;
import org.bson.Document;
import java.io.Serializable;
import java.util.List;
/**
* @author 刘镇 ([email protected]) on 15/11/21 下午12:07
* @version 1.0
*/
public interface IMongoSession extends ISessionBase {
/**
* @return 获取数据库对象
*/
IMongoDatabaseHolder getDatabaseHolder();
/**
* @param 指定结果集数据类型
* @param entity 实体对象
* @return 根据实体执行查询,返回全部结果数据
* @throws Exception 可能产生的异常
*/
IResultSet find(Class entity) throws Exception;
/**
* @param 指定结果集数据类型
* @param entity 实体对象
* @param orderBy 排序条件
* @return 根据实体执行查询,返回全部结果数据
* @throws Exception 可能产生的异常
*/
IResultSet find(Class entity, OrderBy orderBy) throws Exception;
/**
* @param 指定结果集数据类型
* @param entity 实体对象
* @param page 分页查询对象
* @return 根据实体执行分页查询
* @throws Exception 可能产生的异常
*/
IResultSet find(Class entity, Page page) throws Exception;
/**
* @param 指定结果集数据类型
* @param entity 实体对象
* @param orderBy 排序条件
* @param page 分页查询对象
* @return 根据实体执行分页查询
* @throws Exception 可能产生的异常
*/
IResultSet find(Class entity, OrderBy orderBy, Page page) throws Exception;
/**
* @param 指定结果集数据类型
* @param entity 实体对象
* @param filter 过滤条件
* @return 根据指定key条件执行查询,返回结果集中第一条数据
* @throws Exception 可能产生的异常
*/
T findFirst(Class entity, Query filter) throws Exception;
/**
* @param 指定结果集数据类型
* @param entity 实体对象
* @param id 记录Id
* @return 通过ID查找指定的实体对象
* @throws Exception 可能产生的异常
*/
T find(Class entity, Serializable id) throws Exception;
/**
* @param 指定实体类型
* @param entity 实体类对象
* @return 计算查询结果总记录数量
* @throws Exception 可能产生的异常
*/
long count(Class entity) throws Exception;
/**
* @param 指定实体类型
* @param entity 实体类对象
* @param filter 过滤条件
* @return 计算查询结果总记录数量
* @throws Exception 可能产生的异常
*/
long count(Class entity, Query filter) throws Exception;
boolean exists(Class entity, Serializable id) throws Exception;
boolean exists(Class entity, Query filter) throws Exception;
AggregateIterable aggregate(Class entity, Class resultClass, Aggregation... aggregations) throws Exception;
DistinctIterable distinct(Class entity, Class resultClass, String fieldName) throws Exception;
DistinctIterable distinct(Class entity, Class resultClass, String fieldName, Query query) throws Exception;
MapReduceIterable mapReduce(Class entity, Class resultClass, String mapFunction, String reduceFunction) throws Exception;
MapReduceIterable mapReduce(Class entity, String mapFunction, String reduceFunction) throws Exception;
/**
* @param 指定结果集数据类型
* @param entity 实体对象
* @return 根据实体执行更新,返回更新之前的实体对象
* @throws Exception 可能产生的异常
*/
T update(T entity) throws Exception;
/**
* @param 指定结果集数据类型
* @param entity 实体对象
* @param filter 更新字段过滤集合
* @return 根据实体执行更新,返回更新之前的实体对象
* @throws Exception 可能产生的异常
*/
T update(T entity, Fields filter) throws Exception;
/**
* @param 指定结果集数据类型
* @param entities 实体对象集合
* @return 根据实体执行批量更新,返回更新之前的实体对象集合
* @throws Exception 可能产生的异常
*/
List update(List entities) throws Exception;
/**
* @param 指定结果集数据类型
* @param entities 实体对象集合
* @param filter 更新字段过滤集合
* @return 根据实体执行批量更新,返回更新之前的实体对象集合
* @throws Exception 可能产生的异常
*/
List update(List entities, Fields filter) throws Exception;
/**
* @param 指定结果集数据类型
* @param entity 实体对象
* @return 根据实体执行记录插入,返回插入后的实体对象
* @throws Exception 可能产生的异常
*/
T insert(T entity) throws Exception;
/**
* @param 指定结果集数据类型
* @param entities 实体对象集合
* @return 根据实体执行记录批量插入,返回插入后的实体对象集合
* @throws Exception 可能产生的异常
*/
List insert(List entities) throws Exception;
/**
* @param 指定结果集数据类型
* @param entity 实体对象
* @return 根据实体执行记录删除,返回删除之前的实体对象
* @throws Exception 可能产生的异常
*/
T delete(T entity) throws Exception;
T delete(Class entity, Serializable id) throws Exception;
/**
* @param 指定结果集数据类型
* @param entities 实体对象集合
* @return 根据实体执行记录批量删除,返回删除之前的实体对象集合
* @throws Exception 可能产生的异常
*/
List delete(List entities) throws Exception;
List delete(Class entity, Params ids) throws Exception;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy