假设我有:
case class SomeModel(
id : Pk[Long],
description : String
)
object SomeModel extends Magic[SomeModel] {
def ayDogAy = {
var aydog = SomeModel(NotAssigned, "aydog")
this.insert(aydog)
}
}
如何取回插入的 aydog id?
如果重要的话,我的后备数据库是 Postgres
最佳答案
在游戏 2 中,如果您有一个自动增量长 PK:
val id: Long = SQL("insert into bla bla bla").on("bleh", "blah").executeInsert().get
关于postgresql - 使用 Play Framework Anorm,如何获取插入时自动生成的 id?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9641553/