I want to create an object and save it ionto the DB
Log l = new Log();
l.setTimestamp("creation_date", Util.getCurrentTimestamp());
l.setString("app_name", "name");
l.setString("log_type", "type");
l.setLong("user_id", 9l);
l.setLong("module_element_id", 9);
l.set("info", JsonHelper.toJsonString("{}"));
l.save();
I've tried mutiple silution but always get this error:
ERROR: column "info" is of type jsonb but expression is of type character varying
How to insert a jsonb?
edit (DDL):
-- Table: public.log
-- DROP TABLE public.log;
CREATE TABLE public.log
(
id bigint NOT NULL DEFAULT nextval('log_id_seq'::regclass),
creation_date timestamp without time zone,
app_name text,
log_type text,
user_id bigint,
module_element_type bigint,
info jsonb,
CONSTRAINT log_pkey PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
ALTER TABLE public.log
OWNER TO postgres;
This implementation is missing in the framework currently. It was already reported in https://github.com/javalite/activejdbc/issues/640. If you can help tracking down Postgres documentation for all the Postgres data types where this syntax is used with PreparedStatement:
UPDATE my_table SET status = ?::status_type WHERE id = ?
I will then be in a position to quickly implement it for the PostgreSQL dialect: https://github.com/javalite/activejdbc/blob/master/activejdbc/src/main/java/org/javalite/activejdbc/dialects/PostgreSQLDialect.java
Update Jan 4 2022:
The implementation was added to the SNAPSHOT-3.0 and will make it to a next release 3.0 for Java 16.
You can see the discussion here: https://github.com/javalite/javalite/issues/640