All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.easy.query.api4j.client.EasyQuery Maven / Gradle / Ivy

There is a newer version: 2.3.3
Show newest version
package com.easy.query.api4j.client;

import com.easy.query.api4j.delete.EntityDeletable;
import com.easy.query.api4j.delete.ExpressionDeletable;
import com.easy.query.api4j.insert.EntityInsertable;
import com.easy.query.api4j.select.Queryable;
import com.easy.query.api4j.update.EntityUpdatable;
import com.easy.query.api4j.update.ExpressionUpdatable;
import com.easy.query.core.api.client.EasyQueryClient;
import com.easy.query.core.basic.extension.track.EntityState;
import com.easy.query.core.basic.jdbc.parameter.SQLParameter;
import com.easy.query.core.basic.jdbc.tx.Transaction;
import com.easy.query.core.context.QueryRuntimeContext;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * @author xuejiaming
 * @FileName: JQDCClient.java
 * @Description: 文件说明
 * @Date: 2023/2/5 21:27
 */
public interface EasyQuery {
    EasyQueryClient getEasyQueryClient();

    QueryRuntimeContext getRuntimeContext();

    default  List sqlQuery(String sql, Class clazz) {
        return getEasyQueryClient().sqlQuery(sql, clazz);
    }

    default  List sqlQuery(String sql, Class clazz, List parameters) {
        return getEasyQueryClient().sqlQuery(sql, clazz, parameters);
    }

    default  List sqlEasyQuery(String sql, Class clazz, List parameters) {
        return getEasyQueryClient().sqlEasyQuery(sql, clazz, parameters);
    }

    default List> sqlQueryMap(String sql) {
        return getEasyQueryClient().sqlQueryMap(sql);
    }

    default List> sqlQueryMap(String sql, List parameters) {
        return getEasyQueryClient().sqlQueryMap(sql, parameters);
    }

    default long sqlExecute(String sql) {
        return getEasyQueryClient().sqlExecute(sql);
    }

    default long sqlExecute(String sql, List parameters) {
        return getEasyQueryClient().sqlExecute(sql, parameters);
    }

     Queryable queryable(Class clazz);

    default  Queryable queryable(String sql, Class clazz) {
        return queryable(sql, clazz, Collections.emptyList());
    }

     Queryable queryable(String sql, Class clazz, Collection sqlParams);

    default Transaction beginTransaction() {
        return beginTransaction(null);
    }

    /**
     * 数据库隔离级别:
     * Connection.TRANSACTION_READ_UNCOMMITTED,
     * Connection.TRANSACTION_READ_COMMITTED,
     * Connection.TRANSACTION_REPEATABLE_READ,
     * Connection.TRANSACTION_SERIALIZABLE
     *
     * @param isolationLevel null表示不使用任何指定隔离级别,使用默认的
     * @return
     */
    Transaction beginTransaction(Integer isolationLevel);

     EntityInsertable insertable(T entity);

     EntityInsertable insertable(Collection entities);

     ExpressionUpdatable updatable(Class entityClass);

     EntityUpdatable updatable(T entity);

     EntityUpdatable updatable(Collection entities);

     EntityDeletable deletable(T entity);

     EntityDeletable deletable(Collection entities);

     ExpressionDeletable deletable(Class entityClass);

    /**
     * 添加到当前环境的追踪里面
     * 如果当前线程未开启追踪那么添加直接忽略无效
     * 相同对象多次追踪结果还是true
     *
     * @param entity
     * @return true:添加成功,false:已经存在相同对象 或者未开启追踪
     */
    boolean addTracking(Object entity);

    boolean removeTracking(Object entity);

    EntityState getTrackEntityStateNotNull(Object entity);
}