Scala ORM to query SQL databases from Scala via concise, type-safe, and familiar case classes and collection operations. Connects to Postgres, MySql, H2, and Sqlite out of the box
194
stars
22
forks
source link
Using the H2Dialect, how does one retrieve auto-generated keys? #8
Originally posted by **aboisvert** April 10, 2024
The H2Dialect doesn't support the 'returning' clause, so I'm wondering what's the recommended way to retrieve auto-generated keys? (e.g. upon insert, it's typical to retrieve a row's generated primary key such as `id`)
This is typically done at a low-level through `JdbcStatement.getGeneratedKeys` but I don't see this capability available through the scalasql abstractions.
https://h2database.com/javadoc/org/h2/jdbc/JdbcStatement.html#getGeneratedKeys--
Discussed in https://github.com/com-lihaoyi/scalasql/discussions/7