Search in sources :

Example 1 with MappedObject16

use of org.simpleflatmapper.beans.MappedObject16 in project mapping-benchmark by arnaudroger.

the class Sql2OSfmBenchmark method main.

public static void main(String[] args) throws SQLException, NamingException {
    ConnectionParam connParam = new ConnectionParam();
    connParam.db = DbTarget.H2;
    connParam.init();
    Sql2o sql2o = new Sql2o(connParam.dataSource);
    org.sql2o.Connection conn = sql2o.open();
    Map<String, String> columnMappings = new HashMap<>();
    columnMappings.put("YEAR_STARTED", "yearStarted");
    SfmResultSetHandlerFactoryBuilder builder = new SfmResultSetHandlerFactoryBuilder();
    builder.setColumnMappings(columnMappings);
    ResultSetHandlerFactory<MappedObject16> factory16 = builder.newFactory(MappedObject16.class);
    try {
        ResultSetIterable<MappedObject16> resultSetIterable = conn.createQuery(Sql2OBenchmark.SELECT_OBJECT16).addParameter("limit", 2).executeAndFetchLazy(factory16);
        for (MappedObject16 o : resultSetIterable) {
            System.out.println("o = " + o);
        }
    } finally {
        conn.close();
    }
}
Also used : MappedObject16(org.simpleflatmapper.beans.MappedObject16) HashMap(java.util.HashMap) ConnectionParam(org.simpleflatmapper.db.ConnectionParam) SfmResultSetHandlerFactoryBuilder(org.simpleflatmapper.sql2o.SfmResultSetHandlerFactoryBuilder) Sql2o(org.sql2o.Sql2o)

Example 2 with MappedObject16

use of org.simpleflatmapper.beans.MappedObject16 in project mapping-benchmark by arnaudroger.

the class JdbcManualBenchmark method init.

@Setup
public void init() {
    mapper4 = new RowMapper<MappedObject4>() {

        @Override
        public MappedObject4 map(ResultSet rs) throws Exception {
            MappedObject4 o = new MappedObject4();
            o.setId(rs.getLong(1));
            o.setName(rs.getString(2));
            o.setEmail(rs.getString(3));
            o.setYearStarted(rs.getInt(4));
            return o;
        }
    };
    mapper16 = new RowMapper<MappedObject16>() {

        @Override
        public MappedObject16 map(ResultSet rs) throws Exception {
            MappedObject16 o = new MappedObject16();
            o.setId(rs.getLong(1));
            o.setName(rs.getString(2));
            o.setEmail(rs.getString(3));
            o.setYearStarted(rs.getInt(4));
            o.setField5(rs.getShort(5));
            o.setField6(rs.getInt(6));
            o.setField7(rs.getLong(7));
            o.setField8(rs.getFloat(8));
            o.setField9(rs.getDouble(9));
            o.setField10(rs.getShort(10));
            o.setField11(rs.getInt(11));
            o.setField12(rs.getLong(12));
            o.setField13(rs.getFloat(13));
            o.setField14(rs.getDouble(14));
            o.setField14(rs.getDouble(14));
            o.setField15(rs.getInt(15));
            o.setField16(rs.getInt(16));
            return o;
        }
    };
}
Also used : MappedObject16(org.simpleflatmapper.beans.MappedObject16) ResultSet(java.sql.ResultSet) MappedObject4(org.simpleflatmapper.beans.MappedObject4) Setup(org.openjdk.jmh.annotations.Setup)

Aggregations

MappedObject16 (org.simpleflatmapper.beans.MappedObject16)2 ResultSet (java.sql.ResultSet)1 HashMap (java.util.HashMap)1 Setup (org.openjdk.jmh.annotations.Setup)1 MappedObject4 (org.simpleflatmapper.beans.MappedObject4)1 ConnectionParam (org.simpleflatmapper.db.ConnectionParam)1 SfmResultSetHandlerFactoryBuilder (org.simpleflatmapper.sql2o.SfmResultSetHandlerFactoryBuilder)1 Sql2o (org.sql2o.Sql2o)1