You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried execute a insert statement with binded object, I mapped some property to its column, but the error continue (org.sql2o.Sql2oException: Error in executeUpdate, Values not bound to statement). Apparently columns mapping is only used in select statement. Is there some impediment to use it in insert/update too?
It works, the class's field "fieldA" matches with table's column. But the example 2 does not work.
Example 2:
public static void main(String[] args) {
Sql2o sql2o = new Sql2o("jdbc:sqlite:/tmp/test.db", null, null);
Map<String, String> mapColumn = new HashMap<>();
mapColumn.put("field_b", "fieldB");
sql2o.setDefaultColumnMappings(mapColumn); //trying to map the columns
try (Connection conn = sql2o.open()) {
String insert = "insert into config (field_b) values (:field_b)";
conn.createQuery(insert).bind(new Config("a", "b"))
.addColumnMapping("field_b", "fieldB") //trying to map the columns
.executeUpdate();
}
}
I tried to map the column "field_b" to field "fieldB". But it throws the exception bellow.
Caused by: java.sql.SQLException: Values not bound to statement
at org.sqlite.core.CorePreparedStatement.checkParameters(CorePreparedStatement.java:69)
at org.sqlite.jdbc3.JDBC3PreparedStatement.executeUpdate(JDBC3PreparedStatement.java:100)
at org.sql2o.Query.executeUpdate(Query.java:656)
I tried execute a insert statement with binded object, I mapped some property to its column, but the error continue (org.sql2o.Sql2oException: Error in executeUpdate, Values not bound to statement). Apparently columns mapping is only used in select statement. Is there some impediment to use it in insert/update too?
conn.createQuery(INSERT).bind(config).executeUpdate().getKey()
The text was updated successfully, but these errors were encountered: