org.sfm.jdbc.impl.AbstractDynamicJdbcMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simpleFlatMapper Show documentation
Show all versions of simpleFlatMapper Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
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;
}