Created
April 21, 2012 10:38
-
-
Save hexx/2436483 to your computer and use it in GitHub Desktop.
Google App Engine Low Level API Put and Get Sample
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 com.google.appengine.api.datastore.{ DatastoreServiceFactory, Entity } | |
val ds = DatastoreServiceFactory.getDatastoreService | |
val kind = "Person" | |
// データ定義 | |
case class Person(name: String, age: Long) | |
// 保存 | |
val p = Person("John", 13) | |
val e = new Entity(kind) | |
e.setProperty("name", p.name) | |
e.setProperty("age", p.age) | |
val key = ds.put(e) | |
// 取得 | |
val e2 = ds.get(key) | |
val p2 = Person(e2.getProperty("name").asInstanceOf[String], e2.getProperty("age").asInstanceOf[Long]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment