-
Notifications
You must be signed in to change notification settings - Fork 76
Sfm integration in Jooq And Sql2o for performance
Arnaud Roger edited this page Jan 26, 2015
·
2 revisions
If you use sfm to fetch the record for Jooq - not as a mapper but directly from the fetchResultSet() - or using it as the mapper in sql2o you can observe the following gain on java 8 mysql.
private JdbcMapper<SmallBenchmarkObject> mapper = JdbcMapperFactory.newInstance().newMapper(SmallBenchmarkObject.class);
...
ResultSet resultSet =
dslSfmMapping
.select()
.from("test_small_benchmark_object")
.fetchResultSet();
try {
mapper.forEach(resultSet, this:doSomething);
} finally {
resultSet.close();
}
private final ResultSetHandlerFactory<SmallBenchmarkObject> factory =
new SfmResultSetHandlerFactoryBuilder().newFactory(SmallBenchmarkObject.class);
...
try (org.sql2o.Connection conn = sql2o.open()) {
List<?> list = conn
.createQuery("SELECT id, name, email, year_started as yearStarted FROM test_small_benchmark_object")
.executeAndFetch(factory);
for(Object o : list) {
doSomething(o);
}
}