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

cn.vonce.sql.orm.mapper.SpringJbdcSqlBeanMapper Maven / Gradle / Ivy

package cn.vonce.sql.orm.mapper;

import cn.vonce.sql.uitls.SqlBeanUtil;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;

/**
 * Spring jdbc 结果映射
 *
 * @author Jovi
 * @version 1.0
 * @email [email protected]
 */
public class SpringJbdcSqlBeanMapper extends SqlBeanMapper implements RowMapper {

    public Class clazz;
    public Class returnType;

    public SpringJbdcSqlBeanMapper(Class clazz, Class returnType) {
        this.clazz = clazz;
        this.returnType = returnType;
    }

    @Override
    public T mapRow(ResultSet resultSet, int index) {
        Object object;
        if (SqlBeanUtil.isMap(returnType.getName())) {
            object = super.mapHandleResultSet(resultSet);
        } else if (!SqlBeanUtil.isBaseType(returnType.getName())) {
            object = super.beanHandleResultSet(clazz, resultSet, super.getColumnNameList(resultSet));
        } else {
            object = super.baseHandleResultSet(resultSet);
        }
        return (T) object;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy