LoginSignup
0
0

More than 5 years have passed since last update.

Slickでいつの間にかjava.time.*がサポートされてた話

Last updated at Posted at 2019-02-23

私の3時間を返せ

いままでカラムにjava.time.LocalDateとか割り当てる場合は暗黙の変換で以下のようにしていた・・・

implicit val localDateColumnType = MappedColumnType.base[java.time.LocalDate, java.sql.Date](
  t => java.sql.Date.valueOf(t),
  u => u.toLocalDate
)

たぶんバージョン3.3以降でこれを書いてるとコンパイルが通らない。

ついでにmysql-connector-javaの6系もサポートした模様。

【追記】

MySQLのdatetimetimestampが変換できないのでソース見てみたら

/**
* [[LocalDateTime]] will be persisted as a [[java.sql.Types.VARCHAR]] in order to
* avoid losing precision, because MySQL stores [[java.sql.Types.TIMESTAMP]] with
* second precision, while [[LocalDateTime]] stores it with a millisecond one.
*/

だってさ。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0