diff options
author | Jan Christopher Vogt <oss.nsp@cvogt.org> | 2015-08-09 19:08:24 -0400 |
---|---|---|
committer | Jan Christopher Vogt <oss.nsp@cvogt.org> | 2015-08-09 19:08:24 -0400 |
commit | 63c3a0246d903def3ed7b3845ecd108e03ddeaa1 (patch) | |
tree | 17e63ee59ff1f218e0692cd414a3d1b31a2930f1 /src | |
parent | b40dfa417eaf77216ebe5df7d2a80dd6f521dd02 (diff) | |
parent | 76ee13c8818bb386ba94a5c02037deb0ed7046c9 (diff) | |
download | slick-codegen-example-63c3a0246d903def3ed7b3845ecd108e03ddeaa1.tar.gz slick-codegen-example-63c3a0246d903def3ed7b3845ecd108e03ddeaa1.tar.bz2 slick-codegen-example-63c3a0246d903def3ed7b3845ecd108e03ddeaa1.zip |
Merge pull request #2 from krrrr38/slick3.0.1
Update build for 3.0.1
Diffstat (limited to 'src')
-rw-r--r-- | src/main/scala/Example.scala | 7 | ||||
-rw-r--r-- | src/main/sql/create.sql | 4 |
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.'); |