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

org.sfm.jdbc.impl.AbstractDynamicJdbcMapper Maven / Gradle / Ivy

Go to download

Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.

There is a newer version: 1.10.3
Show newest version
package org.sfm.jdbc.impl;

import org.sfm.jdbc.JdbcMapper;
import org.sfm.map.Mapper;
import org.sfm.map.MappingContext;
import org.sfm.map.MappingException;
import org.sfm.utils.ErrorHelper;

import java.sql.ResultSet;
import java.sql.SQLException;


public abstract class AbstractDynamicJdbcMapper implements JdbcMapper {

    @Override
    public final T map(ResultSet source) throws MappingException {
        return map(source, null);
    }

    @Override
    public final T map(ResultSet source, MappingContext mappingContext) throws MappingException {
        try {
            return getMapper(source).map(source, mappingContext);
        } catch(Exception e) {
            return ErrorHelper.rethrow(e);
        }
    }

    @Override
    public final void mapTo(ResultSet source, T target, MappingContext mappingContext) throws Exception {
        getMapper(source).mapTo(source, target, mappingContext);
    }

    protected abstract Mapper getMapper(ResultSet source) throws SQLException;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy