aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/Example.scala7
-rw-r--r--src/main/sql/create.sql4
2 files changed, 6 insertions, 5 deletions
diff --git a/src/main/scala/Example.scala b/src/main/scala/Example.scala
index ffa964b..3eaf9d3 100644
--- a/src/main/scala/Example.scala
+++ b/src/main/scala/Example.scala
@@ -2,7 +2,8 @@ object Tables extends{ // or just use object demo.Tables, which is hard-wired to
val profile = scala.slick.driver.H2Driver
} with demo.Tables
import Tables._
-import Tables.profile.simple._
+import Tables.profile.api._
+import scala.concurrent.ExecutionContext.Implicits.global
object Example extends App {
// connection info for a pre-populated throw-away, in-memory db for this demo, which is freshly initialized on every run
@@ -13,8 +14,8 @@ object Example extends App {
val q = Companies.join(Computers).on(_.id === _.manufacturerId)
.map{ case (co,cp) => (co.name, cp.name) }
- db.withTransaction { implicit session =>
- println( q.run.groupBy{ case (co,cp) => co }
+ db.run(q.result).foreach { result =>
+ println(result.groupBy{ case (co,cp) => co }
.mapValues(_.map{ case (co,cp) => cp })
.mkString("\n")
)
diff --git a/src/main/sql/create.sql b/src/main/sql/create.sql
index 27d5034..22f290e 100644
--- a/src/main/sql/create.sql
+++ b/src/main/sql/create.sql
@@ -1,5 +1,5 @@
-create table "COMPUTERS" ("ID" INTEGER NOT NULL,"NAME" VARCHAR NOT NULL,"MANUFACTURER_ID" INTEGER NOT NULL);
-create table "COMPANIES" ("ID" INTEGER NOT NULL,"NAME" VARCHAR NOT NULL);
+create table IF NOT EXISTS "COMPUTERS" ("ID" INTEGER NOT NULL,"NAME" VARCHAR NOT NULL,"MANUFACTURER_ID" INTEGER NOT NULL);
+create table IF NOT EXISTS "COMPANIES" ("ID" INTEGER NOT NULL,"NAME" VARCHAR NOT NULL);
insert into "COMPANIES" values (1,'Apple Inc.');