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

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -