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
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:
- You do not need
JDATE
- you do not really want to use it anywhere, you want indate time
and UsecolumnTime
for typeinstead of column [JDATE] should be able to translate between
)timestamp
(e.g.column [dateTime] ("birthday")
Nmdin ") -
You really embedded in
DateTime & lt; & gt; timestamp
converter, so it never Slick'scolumn < / 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
Post a Comment