thoughts about software and sensible security.

Just another reason to avoid hibernate – revisited


My previous love affair with Scala has cooled a little since I discovered Kotlin, which is my language of choice for new projects. However, I did produce a light-weight Scala library at the time to make JDBC queries easy and transparent, with a gentle learning curve and a minimum of boilerplate. Recently I brushed up a little and upgraded the dependencies. You can find it on my gitlab.

In Jartah you define database metadata as Scala objects. Tables and columns become available as objects and their members.
This lets you build queries that take full advantage of type safety and Scala operator notation:

import acme.db.Person._
val employeeIds: List[(Long,String)] = session select(id,name) from Person where department in ("HR","FIN") and salary gt 3200.30 or (department ne "DEV" and salary lt 5000) getListAsTuple2(LongColumn,StringColumn)

IDE auto-completion comes standard without need for a plugin:


( is of class Column[Long], and requires a Long parameter)


(height and width are of Column[Dimension]. Values are constructed through implicit methods
that take a Double for meters, and an Int for centimeters. Read more.)

Cool, I want it!

There is an older  beta release on Sonatype. You can include it by adding it to your managed  dependencies in any sbt project, but I suggest you clone it directly from gitlab:

libraryDependencies += "com.jartah" % "jartah" % "0.4.beta6"

The API may change somewhat, hence the beta status. More integration and
performance testing is also needed before it is recommended for production use.

Yet another ORM framework?

Yes, Jartah has (very basic) ORM support, but first and foremost it is a a tool to make SQL more fun in Scala. Coming from an Oracle/PLSQL background, I believe ORM has a limited
set of use cases, yet often I see it implemented in projects for which it is entirely
unsuitable. If you are comfortable with SQL and (more importantly!) your application’s performance is at stake, why not give it a try.

I hope you’ll find it Just Another Reason To Avoid Hibernate.

Add comment

thoughts about software and sensible security.

Recent Posts

Jasper on twitter

Catching thought criminals in Orwell's analogue dictatorship was time-consuming and ineffective. A.I. will fix all…
h J R
I expect Mars to be successfully colonized long before we have flawless PDF to Word conversion.
h J R
Don’t tout #kotlin conciseness as a unique selling point. Concise does not equate understandable and if concise is…
h J R
Hilfiger gives ‘smart dress’ a whole new meaning with new tracking chip.
h J R
ATDD is really different. Think of it as All Tests Drive Development. New blog post.
h J R