问题
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