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

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

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

import io.github.jinghui70.rainbow.dbaccess.mapper.MapRowMapper;
import org.springframework.dao.DataAccessException;

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

/**
 * 封装了一个Sql的内容对象
 *
 * @author lijinghui
 */
public class Sql extends GeneralSql {

    protected Sql() {
        super();
    }

    public Sql(String str) {
        super(str);
    }

    public Sql(Dba dba) {
        super(dba);
    }

    public  ObjectSql from(Class queryClass) {
        return new ObjectSql<>(dba, queryClass).append(getSql()).from(DbaUtil.tableName(queryClass));
    }

    public List> queryForList() throws DataAccessException {
        return queryForList(MapRowMapper.INSTANCE);
    }

    public PageData> pageQuery(int pageNo, int pageSize) {
        return pageQuery(MapRowMapper.INSTANCE, pageNo, pageSize);
    }

    public List> queryForTree() {
        return queryForTree(MapRowMapper.INSTANCE);
    }

    public  Map> queryToMap(ResultSetFunction keyFunc) {
        return queryToMap(keyFunc, MapRowMapper.INSTANCE);
    }

    public  Map>> queryToGroup(ResultSetFunction keyFunc) {
        return queryToGroup(keyFunc, MapRowMapper.INSTANCE);
    }

    public static Sql create() {
        return new Sql();
    }

    public static Sql create(String str) {
        return new Sql(str);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy