2013-02-04 40 views
1

我正在嘗試使用Slick的貼圖投影(版本1.0.0-RC1)。但下面的代碼,以下的網站上的例子(因爲似乎沒有是任何適當的文件,也沒有可用scaladocs)產生了一個類型錯誤:嘗試使用Slick的映射投影時輸入錯誤

object PDFDocs extends Table[(String,Option[String],String)]("DOCUMENTS"){ 
    def id = column[String]("ID", O.PrimaryKey) 
    def title = column[Option[String]]("TITLE") 
    def tags = column[String]("TAGS") 
    def * = (id ~ title ~ tags).<>[PDFDocument](PDFDocument,PDFDocument unapply _) 
} 

case class PDFDocument(name: String, 
         title: Option[String], 
         tags: String) 

這裏是產生錯誤:

error: type mismatch; 
found: scala.slick.lifted.MappedProjection[docman.rdb.PDFDocument,(String,Option[String], String)] 
required: scala.slick.lifted.ColumnBase[(String, Option[String], String)] 
def * = (id ~ title ~ tags).<>[PDFDocument](PDFDocument,PDFDocument unapply _) 

回答

9

關閉我的頭頂,不應該第一行是:

object PDFDocs extends Table[PDFDocument]("DOCUMENTS") { 
+0

這就是「甚至」漂亮和作品。謝謝,我在示例中忽略了這一點。 – ziggystar

+0

+1剛剛發生在我身上的同樣的問題,謝謝:) – stephanos

+1

+100。我一直在尋找答案,我看到的所有樣本都有基於成員參數化的表類,而不是整個模型案例類。我整天都把頭撞在牆上。謝謝。 –