I have a table definition
class Transaction(
val ...
) extends KeyedEntity[Long] {
val id:Long = 0
}
val transaction = table[Transaction]("transactions")
on(transaction) {t =>
declare(
t.id is unique
... (other fields)
)
}
The database table was not generated by Squeryl (I created it manually), but the "ID" column is set to PrimaryKey and AutoIncrement.
Now I'm inserting a row in this table:
val row = new Transaction(...)
val rowResult = transaction.insert(row)
println("Id1="+row.id+"; Id2="+rowResult.id)
The row is correctly inserted into the database and there an ID is assigned (!=0). But the application prints "ID1=0; ID2=0" on the command line.
Why? And how do I get the assigned ID?
edit: I did also try the table definition this way
class Transaction(
val id: Long,
...
) extends KeyedEntity[Long]
Didn't make any differences.