我在下面有交易者
val transactor: Resource[IO, HikariTransactor[IO]] =
for {
ce <- ExecutionContexts.fixedThreadPool[IO](32) // our connect EC
be <- Blocker[IO] // our blocking EC
xa <- HikariTransactor.newHikariTransactor[IO](
"com.mysql.cj.jdbc.Driver",
"jdbc:mysql://localhost:3306/ems",
"username",
"password",
ce,
be
)
} yield xa
我正在使用以下代码查询 mysql
val table = "companies"
val keyCol = "id"
val columns = List("address",
"city",
"companyname",
"email",
"mobile",
"id",
"registerdate",
"registrationexp")
val queryString =
s"""SELECT ${columns.mkString(", ")}
FROM $table WHERE $keyCol = ? """
log.debug(s"$queryString")
transactor.use { xa =>
{
Query[Int, Company](queryString).option(id).transact(xa)
}
}
公司是具有上述列名的案例类
但低于错误
java.lang.ClassCastException: Cannot cast scala.Some to Company
我在哪里做错了
提前致谢