Column mappings - can they be mapped per-object/table?

Skip to first unread message

Oct 3, 2016, 7:36:26 PM10/3/16
to sql2o
Having had bad experiences with hibernate, it seemed like sql2o is exactly what I've been looking for - cleans up jdbc boilerplate including copying object properties over, but otherwise I just write regular sql. 

The one concern I have looking through it is the "Columns Mappings" section -

Like say I have:

- name (object name "firstName")
- lastName

- name (object name "fullName")

But it looks from the docs like I might be screwed if I tried to use default column mappings for these, I'd end up with:
Map<String, String> colMaps = new HashMap<String,String>();
colMaps.put("name", "firstName");
colMaps.put("name", "fullName");

Which would not work like I want because the second key would override the first.
Is there a way to do these mappings per-table other than writing out the mappings for each query I write?

Oct 5, 2016, 10:53:40 PM10/5/16
to sql2o,
Lol...(silence)...crickets chirping...

Lars Aaberg

Oct 7, 2016, 6:09:43 AM10/7/16
to sql2o,
It is not possible to add column mappings per table, but you can add column mappings per query.

try (Connection connection = {
connection.createQuery("select ...")
.addColumnMapping("name", "firstName")
.addParameter("...", "...")
Sorry for the late reply, btw :)

Lars Aaberg

On Thu, Oct 6, 2016 at 4:53 AM <> wrote:
Lol...(silence)...crickets chirping...

You received this message because you are subscribed to the Google Groups "sql2o" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit

Oct 11, 2016, 5:16:26 PM10/11/16
to sql2o,
Thanks for the reply. :-)

Bummer though, looks like unfortunately that removes it from my list and the search for a simple jdbc framework continues for me. :-/
Reply all
Reply to author
0 new messages