光滑 - 创建模式,可选blob获取ERROR:type" lo"不存在

时间:2016-01-13 09:26:55

标签: postgresql scala playframework slick

我正在使用PlaygreSQL和光滑的Play评估

这是模特:

case class Employee(id: Int,first:String,last:String,title:String,pic: Option[Blob])
class Employees(tag:Tag) extends Table[Employee](tag,"EMPLOYEES"){
  def id = column[Int]("ID",O.PrimaryKey, O.NotNull)
  def first = column[String]("LAST", O.NotNull)
  def last = column[String]("LAST", O.NotNull)
  def title = column[String]("TITLE")
  def pic = column[Blob]("PICTURE",O.Nullable)
  override def * = (id,first,last,title,pic.?)<> (Employee.tupled,Employee.unapply)
}

但我得到了这个

  

错误:输入&#34; lo&#34;不存在

创建的sql显示:

create table "EMPLOYEES" ("ID" INTEGER NOT NULL PRIMARY KEY,"LAST" VARCHAR(254) NOT NULL,"TITLE" VARCHAR(254) NOT NULL,"PICTURE" lo);

这是&#34; lo&#34;类型来自哪,我该如何解决?

1 个答案:

答案 0 :(得分:0)

你可以在你的班级Employees中加入两个隐含的方法并试试吗?

private implicit def blob2Bytes(blob: java.sql.Blob): Array[Byte] = {
  if (blob.length == 0)
    return Array[Byte]()
  val r = blob.getBytes(1, blob.length.toInt)
  blob.free
  r
}

private implicit def bytes2Blob(bytes: Array[Byte]) = {
  new SerialBlob(bytes)
}