javaapache-commons-dbutils

Apache DButils column mapping on insert/update?


Apache DBUtils' BeanHandler can conveniently map data into a bean when using SELECT queries. However, it does not seem to be able to do the same when writing data, so I need to use an error-prone way:

newid = qRunner.insert("insert into table(field1Name, field2Name, ... field5Name) values(?,?,?,?,?)",
        new ScalarHandler<Long>(), field1Value, field2Value, ... field5Value);

For tens of columns, it's easy to mess up the pairing of question marks to column values. Is there a similar lightweight library or some kind of extension to DBUtils that can map fields in both directions? (I know Hibernate, but it's way too heavy for my project.)


Solution

  • I have found it too late for my project, but Persism seems to be able to handle what I need without the hassles of Hibernate.