scala - Slick 2.0: Cannot insert java.sql.Timestamp into a table using HList -


i'm getting class cast exception in script , cannot why. error is:

java.lang.classcastexception: java.sql.timestamp cannot cast scala.product

here's code:

import java.sql.timestamp import scala.slick.driver.mysqldriver.simple._ import scala.slick.collection.heterogenous._ import syntax._ import org.joda.time.datetime import db.dealdao import datetimeimplicits._  // implicitly convert datetime timestamp (and seems work) object datetimeimplicits {    implicit def datetime2timestamp(value : datetime) = new timestamp(value.getmillis)  }  object tryhlist {    class tests(tag: tag) extends table[timestamp :: hnil](tag, "tests") {     def timecol = column[timestamp]("time_col")     def * = (timecol :: hnil)   }    def tests = tablequery[tests]    def createtable = dealdao.db.withsession { implicit session =>     tests.ddl.create   }    def insert(dt: datetime) = dealdao.db.withsession { implicit session =>     tests += (dt :: hnil)   }  }  object main {    def main(args: array[string]): unit = {   //  tryhlist.createtable      tryhlist.insert(new datetime())   } } 

you uncovered bug in slick when using 1-element hlist. submitted fix 2.0.1 (rc1 arrive end of next week): https://github.com/slick/slick/pull/658

unrelated: if don't know it, check out https://github.com/tototoshi/slick-joda-mapper


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -