Using Auto Incrementing fields with PostgreSQL and Slick

前端 未结 7 1943
無奈伤痛
無奈伤痛 2020-12-30 00:43

How does one insert records into PostgreSQL using AutoInc keys with Slick mapped tables? If I use and Option for the id in my case class and set it to None, then PostgreSQL

相关标签:
7条回答
  • 2020-12-30 01:38

    Another trick is making the id of the case class a var

    case class Entity(var id: Long)
    

    To insert an instance, create it like below Entity(null.asInstanceOf[Long])

    I've tested that it works.

    0 讨论(0)
提交回复
热议问题