Created
October 9, 2014 15:31
-
-
Save mocyuto/4b8b007ce36a24732fff to your computer and use it in GitHub Desktop.
update を普通に実装した場合
This file contains 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 Coffees(id: Int, name: String, supId:Int, price: Double) | |
class CoffeesTable(tag: Tag) extends Table[(String, Int, Double, Int, Int)](tag, "coffees") { | |
def id = column[Int]("COF_NAME", O.PrimaryKey) | |
def name = column[String]("name") | |
def supID = column[Int]("SUP_ID") | |
def price = column[Double]("PRICE") | |
def * = (id, name, supID, price) <> (Coffees.tupled, Coffees.unapply) | |
// A reified foreign key relation that can be navigated to create a join | |
} | |
val query = TableQuery[Coffees] | |
def update (coffee: Coffees) = { | |
Database.forURL("jdbc:h2:mem:test1", driver = "org.h2.Driver") withSession { | |
implicit session => | |
query.filter(id===coffee.id).update(coffee) | |
} | |
} | |
def main(args: Array[String]) { | |
update(coffee(1,"starbacks",1,540)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment