Why?

Although Sql2o provides a mapping implementation. It does not support inner objects, factory methods, or joins…

By adding just a 2 lines of code to your queries, you will gain the mapping power and the performance of SimpleFlatMapper.

Give it a try.

Getting Started Sql2o

Maven Central JavaDoc

Setting up the environment

Add the Dependency to your build.

for Maven:

Java 8

<dependency>
    <groupId>org.simpleflatmapper</groupId>
    <artifactId>sfm-sql2o</artifactId>
    <version>3.12.1</version>
</dependency>

Java 6, 7

<dependency>
    <groupId>org.simpleflatmapper</groupId>
    <artifactId>sfm-sql2o</artifactId>
    <version>3.12.1</version>
    <classifier>jdk16</classifier>
</dependency>

Java 9

<dependency>
    <groupId>org.simpleflatmapper</groupId>
    <artifactId>sfm-sql2o</artifactId>
    <version>3.12.1</version>
    <classifier>jdk9ea</classifier>
</dependency>

SQL2o integration

Query query = sql2o.open().createQuery("select * from table");
query.setAutoDeriveColumnNames(true);
query.setResultSetHandlerFactoryBuilder(new SfmResultSetHandlerFactoryBuilder());

List<DbObject> dbObjects = query.executeAndFetch(DbObject.class);