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

io.github.jinghui70.rainbow.dbaccess.ObjectSql Maven / Gradle / Ivy

There is a newer version: 5.2.1
Show newest version
package io.github.jinghui70.rainbow.dbaccess;

import cn.hutool.core.lang.Assert;
import io.github.jinghui70.rainbow.dbaccess.object.BeanMapper;
import io.github.jinghui70.rainbow.utils.TreeNode;
import io.github.jinghui70.rainbow.utils.WrapTreeNode;

import java.util.List;
import java.util.Map;
import java.util.Optional;

public class ObjectSql extends GeneralSql> {

    private final Class queryClass;

    public ObjectSql(Dba dba, Class queryClass) {
        super(dba);
        this.queryClass = queryClass;
    }

    public T queryForObject() {
        return queryForObject(queryClass);
    }

    public Optional queryForObjectOptional() {
        return queryForObjectOptional(BeanMapper.of(queryClass));
    }

    public List queryForList() {
        return queryForList(queryClass);
    }

    public PageData pageQuery(int pageNo, int pageSize) {
        return pageQuery(queryClass, pageNo, pageSize);
    }

    @SuppressWarnings({"unchecked", "rawtypes"})
    public List queryForTree() {
        Assert.isAssignable(TreeNode.class, queryClass);
        return queryForTree((Class) queryClass);
    }

    public List> queryForWrapTree() {
        return queryForWrapTree(queryClass);
    }

    public  Map queryToMap(ResultSetFunction keyFunc) {
        return queryToMap(keyFunc, queryClass);
    }

    public  Map> queryToGroup(ResultSetFunction keyFunc) {
        return queryToGroup(keyFunc, queryClass);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy