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

com.easy.query.api4j.client.DefaultEasyQuery 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.delete.impl.EasyEntityDeletable;
import com.easy.query.api4j.delete.impl.EasyExpressionDeletable;
import com.easy.query.api4j.insert.EasyEntityInsertable;
import com.easy.query.api4j.insert.EntityInsertable;
import com.easy.query.api4j.select.Queryable;
import com.easy.query.api4j.select.impl.EasyQueryable;
import com.easy.query.api4j.update.EntityUpdatable;
import com.easy.query.api4j.update.ExpressionUpdatable;
import com.easy.query.api4j.update.impl.EasyEntityUpdatable;
import com.easy.query.api4j.update.impl.EasyExpressionUpdatable;
import com.easy.query.core.api.client.EasyQueryClient;
import com.easy.query.core.basic.extension.track.EntityState;
import com.easy.query.core.basic.jdbc.tx.Transaction;
import com.easy.query.core.context.QueryRuntimeContext;

import java.util.Collection;

/**
 * @author xuejiaming
 * @Date: 2023/3/6 13:30
 */
public class DefaultEasyQuery implements EasyQuery {
    private final EasyQueryClient easyQueryClient;

    public DefaultEasyQuery(EasyQueryClient easyQueryClient) {
        this.easyQueryClient = easyQueryClient;
    }

    @Override
    public EasyQueryClient getEasyQueryClient() {
        return easyQueryClient;
    }

    @Override
    public QueryRuntimeContext getRuntimeContext() {
        return easyQueryClient.getRuntimeContext();
    }

    @Override
    public  Queryable queryable(Class clazz) {
        return new EasyQueryable<>(easyQueryClient.queryable(clazz));
    }

    @Override
    public  Queryable queryable(String sql, Class clazz, Collection sqlParams) {
        return new EasyQueryable<>(easyQueryClient.queryable(sql, clazz, sqlParams));
    }

    @Override
    public Transaction beginTransaction(Integer isolationLevel) {
        return easyQueryClient.beginTransaction(isolationLevel);
    }

//    @Override
//    public  Insert insert(Class clazz) {
//        return new MySQLInsert<>(clazz,new InsertContext(runtimeContext));
//    }

    @Override
    public  EntityInsertable insertable(T entity) {
        return new EasyEntityInsertable<>(easyQueryClient.insertable(entity));
    }

    @Override
    public  EntityInsertable insertable(Collection entities) {
        return new EasyEntityInsertable<>(easyQueryClient.insertable(entities));
    }

    @Override
    public  ExpressionUpdatable updatable(Class entityClass) {
        return new EasyExpressionUpdatable<>(easyQueryClient.updatable(entityClass));
    }

    @Override
    public  EntityUpdatable updatable(T entity) {
        return new EasyEntityUpdatable<>(easyQueryClient.updatable(entity));
    }

    @Override
    public  EntityUpdatable updatable(Collection entities) {
        return new EasyEntityUpdatable<>(easyQueryClient.updatable(entities));
    }

    @Override
    public  EntityDeletable deletable(T entity) {
        return new EasyEntityDeletable<>(easyQueryClient.deletable(entity));
    }

    @Override
    public  EntityDeletable deletable(Collection entities) {
        return new EasyEntityDeletable<>(easyQueryClient.deletable(entities));
    }


    @Override
    public  ExpressionDeletable deletable(Class entityClass) {
        return new EasyExpressionDeletable<>(easyQueryClient.deletable(entityClass));
    }

    @Override
    public boolean addTracking(Object entity) {
        return easyQueryClient.addTracking(entity);
    }

    @Override
    public boolean removeTracking(Object entity) {
        return easyQueryClient.removeTracking(entity);
    }

    @Override
    public EntityState getTrackEntityStateNotNull(Object entity) {
        return easyQueryClient.getTrackEntityStateNotNull(entity);
    }
}