hov*_*man 6 arrays postgresql scala data-access-layer scalikejdbc
我尝试使用 ScalikeJDBC 访问 PostgreSQL 9.4 中的数组。DDL:
create table itab (
code varchar primary key,
group_list varchar[]
);
Run Code Online (Sandbox Code Playgroud)
在 Scala 应用程序中定义了一个简单的案例类和加载器。
case class Item(code: String, groupSet: List[String])
trait loader {
def loadAllItems: List[Item] = {
insideReadOnly { implicit session =>
sql"select CODE, GROUP_LIST from ITAB"
.map(e => Item(
e.string("code"),
e.array("group_list").asInstanceOf[Buffer[String]]
)).list.apply()
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行一个应用程序时,我得到运行时异常
java.lang.ClassCastException: org.postgresql.jdbc4.Jdbc4Array cannot be cast to scala.collection.mutable.Buffer
Run Code Online (Sandbox Code Playgroud)
我该如何解决?谢谢。霍维曼。
归档时间: |
|
查看次数: |
1273 次 |
最近记录: |