Slick(2) — study note
1. Database Connection:
There are three ways to do Database Connection:
- using a JDBC URL
- using a DataSource
- using a JNDI name
- We can use the Session object’s withTransaction method to create a transaction. The block passed to its executed in a single transaction.
- sorting and filtering
- explicit join:
- implicit join: an implicit cross-join is created with a flagMap operation on a Query (i.e. by introducing more than one generator in a for comprehension)
- Two queries can be concatenated with the ++ (or unionAll) and union operators if they have compatible types. Unlike union which filters out duplicate values, ++ simply concatenates the results of the individual queries, which is usually more efficient.
A query for deleting must only select from a single table.
Inserts are done based on a projection of columns from a single table. When you include an AutoInc column in an insert operation, it is silently ignored, so that the database can generate the proper value.
The query must only return raw columns (not computed values) selected from a single table.