Lighweight Data Mapper (Hibernate/ORMLite alternative)

I am looking for a lightweight library to map the results of raw queries (ResultSet) to Kotlin objects, something like Hibernate but that gives me more control over queries and requires less configuration.

Something like ORMLite is what I am looking for, but ORMLite seems to have some problems with Raw Queries and Date objects.

This is so simple that I could create my own library, but I was wondering if there is something out there that I can use

You can have a look at jooq (https://www.jooq.org/), which is quite low level.

I’d personally suggest to just make the effort to use hibernate as often it’s better in the long run for large-ish projects.

If you are using Spring, then Spring Data JDBC might be worth checking out.

I’d personally suggest to just make the effort to use hibernate as often it’s better in the long run for large-ish projects.

Why “make the effort” to use Hibernate, when using jOOQ is effortless? :wink:

Depending on how simple you want to keep everything I would use either use plain old JDBC (quick and dirty), or something more simple than hibernate, as it was suggested jOOQ.

If you go the JDBC route, and you start abstracting it, stop. You will slowly end up writing your own “partial” ORM, that will probably end up not very good. Usually a lot of thought is put in an ORM, and it’s overkill to build something from scratch. We did this in the past, and the results were terrible.

So what is your actual scenario? Just read the values from a table and you are done, or you are working on a full fledged application that requires a carefully built persistence layer?

1 Like

Hey for me Jooq does not seem low level, requires XML config and you must use its compiled classes…

Maybe I will have to go for Hibernate but for me it complicates things too much. ORMLite is almost right, but it has many bugs.

Not using spring :frowning:

Thanks for the detailed answer!

So I am working on a big backend project using Ktor. The project is multimodule and follows Clean Architecture and Clean code standards.

That’s why I am looking for a lightweight library to just transform my results from SQL queries to Kotlin objects (using annotations if possible).

I am considering writting my ORM that just does that, since most ORMs do too much and get in the way (I want to keep SQL queries raw if possible, the only thing the ORM could help with is updates or deletes)