Skip to content

Instantly share code, notes, and snippets.

@hexx
Created April 21, 2012 10:38
Show Gist options
  • Save hexx/2436483 to your computer and use it in GitHub Desktop.
Save hexx/2436483 to your computer and use it in GitHub Desktop.
Google App Engine Low Level API Put and Get Sample
// 共通部分
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