1
votes

I have a table with only one column (a date). This is how I'm trying to model it in Slick 3.x:

The DB class:

import slick.driver.MySQLDriver.api._
import java.sql.Date
import java.time.LocalDate

class ReportDateDB(tag: Tag) extends Table[ReportDateVO](tag, "report_dates") {

  def reportDate = column[LocalDate]("report_date")

  def * = (reportDate) <> (ReportDateVO.apply, ReportDateVO.unapply)

  implicit val localDateColumnType = MappedColumnType.base[LocalDate, Date](
    d => Date.valueOf(d),
    d => d.toLocalDate
  )

}

The value object case class:

import java.time.LocalDate

case class ReportDateVO(reportDate: LocalDate)

Problem is that I get the following error in the DB class (when I declare the field reportDate):

  • could not find implicit value for parameter tt: slick.ast.TypedType[java.time.LocalDate]
  • not enough arguments for method column: (implicit tt: slick.ast.TypedType[java.time.LocalDate])slick.lifted.Rep[java.time.LocalDate]. Unspecified value parameter tt.

What is this error and how to fix it? The implicit conversion from/to LocalDate/sql.Date is defined.

2

2 Answers

1
votes

You should be able to solve this by supplying the value explicitly:

def reportDate = column[LocalDate]("report_date")(localDateColumnType)
0
votes

In order to keep things implicit and not refer explicitly to localDateColumnType just put its definition before the column definition.