vert-x3/vertx-jdbc-client

ResultSet failed to load JsonObject with custom type

glassfox opened this issue · 3 comments

Version

4.2.0

Context

  1. The data loaded into ResultSet from MySql and contain custom type values LocalDate.
    In try to ResultSet.toJson() and then new ResultSet(JsonObject) got exception.

Following the exception:

java.lang.IllegalStateException: Illegal type in Json: class java.time.LocalDate
	at io.vertx.ext.sql.ResultSetConverter.lambda$1(ResultSetConverter.java:52) ~[classes/:?]
	at io.vertx.ext.sql.ResultSetConverter.fromJson(ResultSetConverter.java:50) ~[classes/:?]
	at io.vertx.ext.sql.ResultSet.<init>(ResultSet.java:66) ~[classes/:?]

Could you provide a simplified example?

Anyway, I think you can provide an SPI for fixing the custom type in your application
Please check #255 (comment)

Not sure if SPI will help in this situation.

JsonObject cannot keep java datetime type, except Instant. But JsonArray can.

The safe way is using loop over ResultSet, then you can access exact data per column