我在用Postgres和Jooq
object JooqBuilder {
private val defaultSettings = new Settings()
.withRenderFormatted(true)
.withRenderNameStyle(RenderNameStyle.AS_IS)
.withParseDialect(SQLDialect.POSTGRES)
def default(conn: Connection) =
DSL.using(conn, SQLDialect.POSTGRES, defaultSettings)
}
字符串
这是我的插页
val insert = JooqBuilder
.default(conn)
.insertInto(
table(MY_TABLE),
field("id", classOf[String]),
field("dimensions", classOf[Array[String]]),
field("dimensionCodes", classOf[Array[Long]])
)
items.foreach { i =>
insert.values(
i.id,
i.dimensions.toArray, // scala List[String] to java array
i.dimensionCodes.toArray // scala List[Long] to java array
)
}
insert.execute()
型
它在运行时失败,
Cause: java.lang.ClassCastException: class [J cannot be cast to class [Ljava.lang.Object; ([J is in module java.base of loader 'bootstrap')
at org.jooq.tools.Convert$ConvertAll.from(Convert.java:520)
at org.jooq.tools.Convert.convert0(Convert.java:324)
at org.jooq.tools.Convert.convert(Convert.java:316)
at org.jooq.tools.Convert.convert(Convert.java:387)
at org.jooq.impl.DefaultDataType.convert(DefaultDataType.java:825)
at org.jooq.impl.InsertImpl.addValue(InsertImpl.java:334)
at org.jooq.impl.InsertImpl.values(InsertImpl.java:314)
at org.jooq.impl.InsertImpl.values(InsertImpl.java:273)
at org.jooq.impl.InsertImpl.values(InsertImpl.java:124)
型
我怀疑i.dimensionCodes.toArray
返回了我检查过的基本类型数组调试器
else if (fromClass.isArray()) {
Object[] fromArray = (Object[]) from;
// [#3062] [#5796] Default collections if no specific collection type was requested
型from
是long[]
有什么变通办法吗?
1条答案
按热度按时间qacovj5a1#
字符串
明确的拳击帮助。