mysql - Joda-Date Mapper for Slick - MappedColumnTyoe -


My problem is very close to this question, but my error is different

< p> this is my utility class which has been JDATE defined Mapper

  package org.mydomain.utils Import slick.driver.MySQLDriver.simple ._ import org.joda.time.DateTime Import java.sql.Date Import org.joda.time.DateTime import java.sql.Timestamp seal featuring JDATE object DateUtils {implicit def jdateColumnType = MappedColumnType.base [DateTime, timestamp] (dt = & Gt; new timestamp (DT. GetMillis), ts = & gt; New DateTime Jetaim))}  

domain object user. Scala is as follows

Case Class UserRow (ID: Long, Birthday: Jedit) Class User (Tags: Tag) Table [UserRow] (tag, "USER") {def id = column} ] ("ID", O. Primary, O. Autoink) Def Deading = Column [JDATE] ("Birthday") DEF * = (ID, Birthday) & lt; & Gt; (UserRow.tupled, UserRow.unapply)}

Error: The method is not sufficient reason for the column: (underlying TM Skla. Slick.ast.TypedType [org.mydomain.utils. JDATE]) scala.slick.lifted.Column [org.mydomain.utils.JDATE]. Unspecified value parameter TM

How to pass TM? Thank you for this noob question

Here are two problems:

  1. You do not need JDATE - you do not really want to use it anywhere, you want in date time and Use columnTime for type instead of column [JDATE] should be able to translate between timestamp (e.g. column [dateTime] ("birthday") Nmdin ") )
  2. You really embedded in DateTime & lt; & gt; timestamp converter, so it never Slick's column < / Code> either by:

      // the built-in import table [Constructor class user (tag: tag) [UserRow] (tag, "USER") {import org.mydomain .utils.DateUtils.jdateColumnType // your code here}  

    or

      // clearly pass the underlying converter itself class user ( Tags: tag) of table [UserRow] Expands (tag, "USER") {// ... cutting ... DR DEF DEADMENT = COLUMN [DATIMEIME] ("Birthday") (DatUtili. Jadeet Colm Type) // ... cutting ...}  

    or (best option), your custom driver has the MySQL driver built into a custom Enhanced with custom:

      package org.mydomain.db Import scala.slick.driver. {MySqlDriver, JdbcDriver} Specialty DateUtils {JDbcDriver with built-in def jdateColumnType = MappedColumnType.base [DateTime, Timestamp] (DT => New Timestamp (dt.getMillis), ts = & gt; New DateTime)) Specialty CustomMySqlDriver MySqlDriver DateUtils object extends along CustomMySqlDriver exten Ds CustomMySqlDriver  

    and then you can use it like this:

      import org.mydomain.db.CustomMySqlDriver. Simple._ class user (tags: tag) table [UserRow] (tag, "user") {// ... cutting ... DR def deadline = column [datetime] ("birthday") // extension ...}  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -