如何在Slick2.0中使用DateTime? [英] How to use DateTime in Slick2.0?

查看:120
本文介绍了如何在Slick2.0中使用DateTime?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Slick 2.0模型中使用DateTime.我使用jodatime:

I want to use DateTime in Slick 2.0 model. I use jodatime:

我在Build.scala中添加了依赖项:

   "joda-time" % "joda-time"    % "2.3",
   "org.joda"  % "joda-convert" % "1.6"

然后我做

 class Comment(tag:Tag) extends Table[(Long, Int, Int, String, Int, DateTime)](tag,"Comment"){
  def id=column[Long]("ID", O.PrimaryKey)
  def rate=column[Int]("rate")
  def sub=column[Int]("subject")
  def content=column[Int]("cotent")
  def user_ID=column[Int]("user")
  def time=column[DateTime]("time")   //-----------an error here
  def * = (id, rate,sub, content, user_ID, time)
}

错误是:

 could not find implicit value for parameter tm: scala.slick.ast.TypedType[org.joda.time.LocalDate]

我添加了joda转换jar,但是它似乎不起作用.如何在Slick模型类中添加DateTime?

I added joda-convert jar but it doesn't seems to work. How to add a DateTime in a Slick model class?

推荐答案

看看 https://github.com/tototoshi/slick-joda-mapper ,否则您必须创建自己的类型映射器

Take a look at https://github.com/tototoshi/slick-joda-mapper or you must create your own type mapper

这篇关于如何在Slick2.0中使用DateTime?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆