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

ninja.cero.sqltemplate.core.mapper.SingleColumnMapper Maven / Gradle / Ivy

There is a newer version: 2.1.0
Show newest version
package ninja.cero.sqltemplate.core.mapper;

import ninja.cero.sqltemplate.core.util.Jsr310JdbcUtils;
import org.springframework.jdbc.core.SingleColumnRowMapper;
import org.springframework.jdbc.support.JdbcUtils;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.ZoneId;

public class SingleColumnMapper extends SingleColumnRowMapper {
    /** ZoneId for OffsetDateTime and ZonedDateTime */
    protected ZoneId zoneId;

    public SingleColumnMapper(Class requiredType, ZoneId zoneId) {
        super(requiredType);
        this.zoneId = zoneId;
    }

    @Override
    protected Object getColumnValue(ResultSet rs, int index, Class requiredType) throws SQLException {
        if (requiredType != null) {
            return Jsr310JdbcUtils.getResultSetValue(rs, index, requiredType, zoneId);
        }
        return JdbcUtils.getResultSetValue(rs, index);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy