我使用以下代码从 mysql 表中请求项目(Account 类只是表示数据库字段的案例类)
val res = Queryable[Account].map(_.name)
val db = Database.forURL("jdbc:mysql://localhost:3306/databasename", driver = "com.mysql.jdbc.Driver", user="username", password="password")
val backend = new SlickBackend(MySQLDriver, AnnotationMapper)
db withSession {
val r=backend.toList(res)
println(r.toString)
}
线
val r=backend.toList(res)
抛出以下异常:
[ToolBoxError: reflective typecheck has failed: ambiguous implicit values: both value StringCanBuildFrom in object Predef of type => scala.collection.generic.CanBuildFrom[String,Char,String] and method conforms in object Predef of type [A]=> <:<[A,A] match expected type T]
可能是什么原因?我正在使用 Scala 2.10.0-RC1 和 Slick 0.11.2。
下面是 Account 类的样子:
@table("account")
case class Account (
@column("ID") id: Long,
...
@column("Name") name: String,
...
)