Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated for sbt 0.11.0, also added constructor definitions so it compiles #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
lib_managed
minimalexample.iml
target

.classpath
.project
.scala_dependencies
.target/
11 changes: 11 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name := "minimalexample"

organization := "org.squeryl"

version := "0.1-SNAPSHOT"

scalaVersion := "2.9.1"

libraryDependencies ++= Seq(
"com.h2database" % "h2" % "1.3.160",
"org.squeryl" %% "squeryl" % "0.9.4")
11 changes: 2 additions & 9 deletions project/build.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
#
#Tue May 03 19:30:41 CEST 2011
project.organization=org.squeryl
project.name=minimalexample
sbt.version=0.7.7
project.version=0.1-SNAPSHOT
build.scala.versions=2.7.7
project.initialize=false
build.scala.versions=2.8.1
sbt.version=0.11.0

6 changes: 0 additions & 6 deletions project/build/ExampleProject.scala

This file was deleted.

2 changes: 0 additions & 2 deletions project/plugins/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions project/plugins/Plugins.scala

This file was deleted.

35 changes: 20 additions & 15 deletions src/main/scala/code/Main.scala
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
package code

import org.squeryl._
import adapters.H2Adapter
import PrimitiveTypeMode._
import org.squeryl.adapters.H2Adapter

object Main {
def main(args: Array[String]) {
Class.forName("org.h2.Driver");
SessionFactory.concreteFactory = Some(()=>
SessionFactory.concreteFactory = Some(() =>
Session.create(
java.sql.DriverManager.getConnection("jdbc:h2:~/example", "sa", ""),
new H2Adapter)
)
new H2Adapter))

inTransaction {
import Library._

drop // Bad idea in production application!!!!
drop // Bad idea in production application!!!!
create
printDdl

Expand All @@ -30,8 +29,7 @@ object Main {

val q = join(books, authors)((b, a) =>
select(b, a)
on(b.authorId === a.id)
)
on (b.authorId === a.id))

for ((book, author) <- q) {
println(author.firstName + " " + author.lastName + " wrote " + book.title)
Expand All @@ -40,15 +38,22 @@ object Main {
}
}

class Author(val id: Long,
val firstName: String,
val lastName: String,
val email: Option[String]) extends KeyedEntity[Long]
class Author(
val id: Long,
val firstName: String,
val lastName: String,
val email: Option[String]) extends KeyedEntity[Long] {

class Book(val id: Long,
val title: String,
val authorId: Long,
val coAuthorId: Option[Long]) extends KeyedEntity[Long]
def this() = this(0, "", "", Some(""))
}

class Book(
val id: Long,
val title: String,
val authorId: Long,
val coAuthorId: Option[Long]) extends KeyedEntity[Long] {
def this() = this(0, "", 0, Some(0L))
}

object Library extends Schema {
val authors = table[Author]
Expand Down