anorm joda-time - localdatetime support

本秂侑毒 提交于 2019-12-08 07:00:45

问题


With Anorm 2.5.2

SQL(s"insert into user (name, registered_date) values ({name},{registered_date})").on(
  'name -> user.name,
  'registered_date -> user.registeredDate
).executeInsert()

Compilation error:

Error:(72, 24) type mismatch; found : (Symbol, org.joda.time.LocalDateTime) required: anorm.NamedParameter 'registered_date -> user.registeredDate

Should I include some implicit Time->Row transformation or it should come out of the box with anorm?

where user:

case class User(id: Option[Long] = None,
                name: String,
                registeredDate: LocalDateTime // joda-time'
               )

回答1:


   import anorm.JodaParameterMetaData._

from here: https://groups.google.com/forum/#!topic/play-framework/I6TnTzO5MUw

(it was nice talking to myself :) )



来源:https://stackoverflow.com/questions/40335038/anorm-joda-time-localdatetime-support

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!