org.sfm.sql2o.SfmResultSetHandlerFactoryBuilder 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.sql2o;
import org.sfm.jdbc.JdbcMapperFactory;
import org.sfm.jdbc.impl.DynamicJdbcMapper;
import org.sfm.map.impl.DefaultPropertyNameMatcherFactory;
import org.sql2o.DefaultResultSetHandlerFactoryBuilder;
import org.sql2o.ResultSetHandlerFactory;
import java.util.Map;
public class SfmResultSetHandlerFactoryBuilder extends DefaultResultSetHandlerFactoryBuilder {
public SfmResultSetHandlerFactoryBuilder() {
super();
}
@Override
public ResultSetHandlerFactory newFactory(Class aClass) {
boolean exactMatch = !isAutoDeriveColumnNames();
DefaultPropertyNameMatcherFactory propertyNameMatcherFactory = new DefaultPropertyNameMatcherFactory(exactMatch, isCaseSensitive());
Map columnMappings = getColumnMappings();
JdbcMapperFactory jdbcMapperFactory = JdbcMapperFactory
.newInstance()
.propertyNameMatcherFactory(propertyNameMatcherFactory);
if (columnMappings != null) {
jdbcMapperFactory.addAliases(columnMappings);
}
DynamicJdbcMapper dynamicJdbcMapper = (DynamicJdbcMapper)
jdbcMapperFactory
.newMapper(aClass);
return new SfmResultSetHandlerFactory(dynamicJdbcMapper);
}
}