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, 9, 10 , 11 no module-info

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

Java 6, 7

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

Java 9, 10 , 11 with module-info

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

From 7.0.0 you will need explicitly include the sql2o dependency in your pom.

SQL2o integration

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

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