我有一个带有String []和Time []数组列的表。从表中读取工作正常。但是当我试图创建一个记录时......
MyTableRecord r = txJooq.newRecord(MY_TABLE);
r.setId(id);
r.setStringArr("foo", "bar");
r.setTimeArr(LocalTime.of(7, 0), LocalTime.of(10, 0));
r.store();
...我收到以下例外情况。
org.jooq.exception.DataAccessException: SQL [null]; Can't infer the SQL type to use for an instance of [Ljava.lang.String;. Use setObject() with an explicit Types value to specify the type to use.
at org.jooq_3.9.1.H2.debug(Unknown Source)
at org.jooq.impl.Tools.translate(Tools.java:1983)
at org.jooq.impl.AbstractBindContext.bindValue(AbstractBindContext.java:130)
at org.jooq.impl.Val.accept(Val.java:96)
at org.jooq.impl.AbstractBindContext.bindInternal(AbstractBindContext.java:257)
at org.jooq.impl.AbstractBindContext.visit0(AbstractBindContext.java:91)
at org.jooq.impl.AbstractContext.visit0(AbstractContext.java:402)
at org.jooq.impl.AbstractContext.visit(AbstractContext.java:168)
at org.jooq.impl.QueryPartList.accept(QueryPartList.java:104)
at org.jooq.impl.AbstractBindContext.bindInternal(AbstractBindContext.java:257)
at org.jooq.impl.AbstractBindContext.visit0(AbstractBindContext.java:91)
at org.jooq.impl.AbstractContext.visit0(AbstractContext.java:402)
at org.jooq.impl.AbstractContext.visit(AbstractContext.java:168)
at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:345)
at org.jooq.impl.AbstractDelegatingQuery.execute(AbstractDelegatingQuery.java:135)
at ch.waschenda.backend.web.control.BootstrapController.createLandlord(BootstrapController.java:66)
at ch.waschenda.backend.web.control.BootstrapController.lambda$bootstrap$0(BootstrapController.java:41)
at com.github.witoldsz.ultm.internal.ThreadLocalTxManager.lambda$tx$2(ThreadLocalTxManager.java:81)
at com.github.witoldsz.ultm.internal.ThreadLocalTxManager.txUnwrappedResult(ThreadLocalTxManager.java:55)
at com.github.witoldsz.ultm.internal.ThreadLocalTxManager.txResult(ThreadLocalTxManager.java:67)
at com.github.witoldsz.ultm.internal.ThreadLocalTxManager.tx(ThreadLocalTxManager.java:81)
at ch.waschenda.backend.web.control.BootstrapController.bootstrap(BootstrapController.java:40)
at ch.waschenda.backend.web.Api.bootstrap(Api.java:67)
at spark.RouteImpl$1.handle(RouteImpl.java:61)
at spark.http.matching.Routes.execute(Routes.java:61)
at spark.http.matching.MatcherFilter.doFilter(MatcherFilter.java:130)
at spark.embeddedserver.jetty.JettyHandler.doHandle(JettyHandler.java:50)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:189)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
at org.eclipse.jetty.server.Server.handle(Server.java:517)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:308)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of [Ljava.lang.String;. Use setObject() with an explicit Types value to specify the type to use.
at org.postgresql.jdbc.PgPreparedStatement.setObject(PgPreparedStatement.java:1051)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.setObject(HikariProxyPreparedStatement.java)
at org.jooq.tools.jdbc.DefaultPreparedStatement.setObject(DefaultPreparedStatement.java:189)
at org.jooq.impl.DefaultBinding.set(DefaultBinding.java:1165)
at org.jooq.impl.DefaultBindContext.bindValue0(DefaultBindContext.java:62)
at org.jooq.impl.AbstractBindContext.bindValue(AbstractBindContext.java:127)
... 38 more
似乎jOOQ正在生成无效的SQL语句。它创建了
values (
...
('foo', 'bar'),
...
);
而不是正确的
values (
...
'{"foo", "bar"}',
...
);
我正在使用:
答案 0 :(得分:2)
愚蠢的我,我用错误的SQL Dialect配置了jOOQ
new DefaultConfiguration().set(SQLDialect.POSTGRES)
诀窍