我下面有交易者
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
我做错了什么
预先感谢