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

org.sfm.sql2o.SfmResultSetHandlerFactoryBuilder 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.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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy