Skip to content

Instantly share code, notes, and snippets.

@takezoe
Created February 12, 2012 05:44
Show Gist options
  • Save takezoe/1806591 to your computer and use it in GitHub Desktop.
Save takezoe/1806591 to your computer and use it in GitHub Desktop.
Getting Started of mirage-scala
case class Book(
@(PrimaryKey @field)(generationType = IDENTITY) bookId: Option[Long],
bookName: String,
author: String,
price: Option[Int]) {
// default constructor
def this() = this(None, null, null, None)
}
resolvers += "amateras-repo" at "http://amateras.sourceforge.jp/mvn/"
libraryDependencies += "jp.sf.amateras.mirage" %% "mirage-scala" % "0.0.3" % "compile"
jdbc.driver=org.h2.Driver
jdbc.url=jdbc:h2:tcp://localhost:9092/test
jdbc.user=sa
jdbc.password=
import jp.sf.amateras.mirage.scala._
Session.withTransaction { session =>
val sqlManager = session.sqlManager
// insert
sqlManager.insertEntity(Book(None, "Mirage in Action", "Naoki Takezoe", Some(20)))
// select by the primary key
val key: Long = 1
val book: Option[Book] = sqlManager.findEntity(classOf[book], key)
...
}
@takezoe
Copy link
Author

takezoe commented Feb 12, 2012

They are code snippets used in the following blog entry:
http://takezoe.blogspot.com/2012/02/getting-started-with-mirage-scala.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment