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

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

The newest version!
package io.github.jinghui70.rainbow.dbaccess;

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

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

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

    public 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);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy