I have table with 3 columns and one of them has 'json' type. When I try to insert values(with empty json, but it doesnt' matter is it empty or not, it doesn't work in any way.) then I get the error:
java.lang.AssertionError: io.vertx.core.impl.NoStackTraceThrowable: Parameter at position[1] with class = [org.jooq.JSON] and value = ["{}"] can not be coerced to the expected class = [java.lang.Object] for encoding.
Here is my code:
@Override
public Future<Void> saveInstances(List<Instances> instances, String tenantId) {
return getQueryExecutor(tenantId).transaction(queryExecutor -> queryExecutor.execute(dslContext -> {
InsertValuesStep3<InstancesRecord, UUID, JSON, String> insertValues = dslContext.insertInto(INSTANCES, INSTANCES.INSTANCE_ID,
INSTANCES.JSON, INSTANCES.REQUEST_ID);
instances.forEach(instance -> insertValues.values(instance.getInstanceId(), instance.getJson(), instance.getRequestId()));
return insertValues;
})
.map(rows -> null));
}
getQueryExecutor(tenantId) returns the ReactiveClassicGenericQueryExecutor object insatnce.getJson() reutns org.jooq.JSON type.
Database is PostgreSQL. I don't want to use any converters and etc. Documentation says that jooq supports JSON and jsonb natively but what is the problem with them here? As well I didn't get rowMappers generated for tables that contain JSON or jsonb columns.
<jooq.version>3.13.2</jooq.version>
<vertx-jooq.generator.version>5.1.1</vertx-jooq.generator.version>
<vertx-jooq.classic-reactive.version>5.2.0</vertx-jooq.classic-reactive.version>
Got confused with that, any suggestions will be helpful. Thank you!