Created
February 12, 2012 05:44
-
-
Save takezoe/1806591 to your computer and use it in GitHub Desktop.
Getting Started of mirage-scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resolvers += "amateras-repo" at "http://amateras.sourceforge.jp/mvn/" | |
libraryDependencies += "jp.sf.amateras.mirage" %% "mirage-scala" % "0.0.3" % "compile" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jdbc.driver=org.h2.Driver | |
jdbc.url=jdbc:h2:tcp://localhost:9092/test | |
jdbc.user=sa | |
jdbc.password= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
They are code snippets used in the following blog entry:
http://takezoe.blogspot.com/2012/02/getting-started-with-mirage-scala.html