auto increment - Squeryl get value of serial -
i insert new row database , id auto-incremented ("serial"). how can value of id after insertion? currently, using following workaround:
intransaction { schema.table.insert(new entry( content = "..." )) def entries = from(schema.table)(e => select(e) orderby(e.id desc)).page(0, 1) val id = entries.headoption match { case some(entry) => entry.id case none => 0 } }
if there no easier way, how can ensure entire block atomic operation?
yes,
val new = schema.table.insert(myoriginalold) console println new.id
Comments
Post a Comment