sql2o is a small library, which makes it easy to convert the result of your sql-statements into objects. No resultset hacking required. Kind of like an orm, but without the sql-generation capabilities. Supports named parameters.
create table product
(
id bigserial not null
constraint product_pk
primary key,
title varchar not null,
created timestamp with time zone default now() not null,
updated timestamp with time zone,
cost double precision default 0 not null,
categories bigint[],
picture varchar
);
There is a problem with categories field.
I want to insert Product object to database.
Running
I get org.sql2o.Sql2oException: Error in executeUpdate, ERROR: INSERT has more expressions than target columns, because the final query looks like insert into delivery.product (title, cost, categories) values (?, ?, ?,?) RETURNING *. One parameter of type List<Long> transformed to two positions in query!
In my case, I have a class Product and table product:
There is a problem with
categories
field.I want to insert
Product
object to database. RunningI get
org.sql2o.Sql2oException: Error in executeUpdate, ERROR: INSERT has more expressions than target columns
, because the final query looks likeinsert into delivery.product (title, cost, categories) values (?, ?, ?,?) RETURNING *
. One parameter of typeList<Long>
transformed to two positions in query!The solution I found is to use
But it is not good idea, I think.
The main question is: can we make Qyery.bind() work with List/Array parameters when
insert
?