Vert.x:包含DateTime的PostgreSql结果未添加到JsonArray

时间:2016-05-25 16:40:42

标签: postgresql jodatime vert.x

我有一个SQL查询,它返回DateTime作为其中一个对象。将它添加到JsonArray时出现错误。

堆栈追踪:

SEVERE: An exception occurred
java.lang.IllegalStateException: Illegal type in JsonObject: class org.joda.time.DateTime
    at io.vertx.core.json.Json.checkAndCopy(Json.java:120)
    at io.vertx.core.json.JsonArray.add(JsonArray.java:437)
    at io.vertx.ext.asyncsql.impl.AsyncSQLConnectionImpl$2.apply(AsyncSQLConnectionImpl.java:286)
    at io.vertx.ext.asyncsql.impl.AsyncSQLConnectionImpl$2.apply(AsyncSQLConnectionImpl.java:274)
    at scala.collection.Iterator$class.foreach(Iterator.scala:743)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1195)
    at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
    at com.github.mauricio.async.db.general.ArrayRowData.foreach(ArrayRowData.scala:22)
    at io.vertx.ext.asyncsql.impl.AsyncSQLConnectionImpl.rowToJsonArray(AsyncSQLConnectionImpl.java:274)
    at io.vertx.ext.asyncsql.impl.AsyncSQLConnectionImpl.access$000(AsyncSQLConnectionImpl.java:46)
    at io.vertx.ext.asyncsql.impl.AsyncSQLConnectionImpl$1.apply(AsyncSQLConnectionImpl.java:265)
    at io.vertx.ext.asyncsql.impl.AsyncSQLConnectionImpl$1.apply(AsyncSQLConnectionImpl.java:262)
    at scala.collection.Iterator$class.foreach(Iterator.scala:743)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1195)
    at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
    at com.github.mauricio.async.db.general.MutableResultSet.foreach(MutableResultSet.scala:27)
    at io.vertx.ext.asyncsql.impl.AsyncSQLConnectionImpl.rowDataSeqToJsonArray(AsyncSQLConnectionImpl.java:262)
    at io.vertx.ext.asyncsql.impl.AsyncSQLConnectionImpl.queryResultToResultSet(AsyncSQLConnectionImpl.java:250)
    at io.vertx.ext.asyncsql.impl.AsyncSQLConnectionImpl.lambda$null$10(AsyncSQLConnectionImpl.java:130)
    at io.vertx.ext.asyncsql.impl.ScalaUtils$3.apply(ScalaUtils.java:81)
    at io.vertx.ext.asyncsql.impl.ScalaUtils$3.apply(ScalaUtils.java:77)
    at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
    at io.vertx.ext.asyncsql.impl.VertxEventLoopExecutionContext.lambda$execute$5(VertxEventLoopExecutionContext.java:70)
    at io.vertx.core.impl.ContextImpl.lambda$wrapTask$18(ContextImpl.java:335)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:358)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
    at java.lang.Thread.run(Thread.java:745)

我相信错误发生在这里:

  private List<JsonArray> rowDataSeqToJsonArray(com.github.mauricio.async.db.ResultSet set) {
    List<JsonArray> list = new ArrayList<>();
    set.foreach(new AbstractFunction1<RowData, Void>() {
      @Override
      public Void apply(RowData row) {
        list.add(rowToJsonArray(row));
        return null;
      }
    });
    return list;
  }

我的Rowdata看起来像这样:

Some(MutableResultSet(ArrayRowData(, , hphan, 2016-04-26T00:00:00.000-07:00, 1), ArrayRowData(, , hphan, 2016-04-28T00:00:00.000-07:00, 2), ArrayRowData(BXBSVA, BLUE CROSS BLUE SHIELD VIRGINIA, null, 2016-04-26T00:00:00.000-07:00, 1)))

有谁知道如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

这应该适用于即将发布的3.3版本。但请注意,异步客户端被标记为技术预览,因此存在粗糙的边缘。

如果您需要更多我建议使用jdbc客户端的功能,请说明。虽然性能不是很高,但功能齐全。