我一直在绞尽脑汁地思考 usingexecuteUpdate()与executeInsert().
在下面的代码中,我使用了executeInsert()
def addEntry(day: DateMidnight, create_time: DateTime, points: Long, src: String) = DB.withTransaction { implicit connection =>
Logger.debug("I got here")
SQL(
"""
INSERT INTO density_cache(day_of, create_time, points, src)
VALUES ({day_of}, {create_time}, {points}, {src})
"""
).on(
'day_of -> day,
'create_time -> create_time,
'points -> points,
'src -> src
).executeInsert()
Logger.debug("Got to 2nd step")
}
Run Code Online (Sandbox Code Playgroud)
我遇到以下问题: Java.lang.RuntimeException: TypeDoesNotMatch(无法将 2013-04-15 13:58:46.0:class java.sql.Timestamp 转换为 Long for 列 ColumnName(密度_cache.day_of,Some(day_of)))
但当我切换到 时executeUpdate(),它工作得很好。