package com.elab.core.dao.params;

import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;

import java.sql.Types;
import java.util.Map;

/**
 * @author : liukx
 * @create : 2018/8/10 14:17
 * @email : liukx@elab-plus.com
 */
public class MapDataSqlParameterSource extends MapSqlParameterSource {


    /**
     * Create a new BeanPropertySqlParameterSource for the given bean.
     *
     * @param values the bean instance to wrap
     */
    public MapDataSqlParameterSource(Map<String, ?> values) {
        super(values);
    }

    @Override
    public Object getValue(String paramName) throws IllegalArgumentException {
        try {
            return super.getValue(paramName);
        } catch (IllegalArgumentException ex) {
            return null;
        }
    }

    @Override
    public int getSqlType(String paramName) {
        try {
            return super.getSqlType(paramName);
        } catch (NullPointerException ex) {
            return Types.VARCHAR;
        }
    }
}
