Advertisement
mikhail_dvorkin

DataStore

Mar 12th, 2017
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. package me.dvorkin;
  2.  
  3. import com.google.appengine.api.datastore.*;
  4.  
  5. public class DataStore {
  6.     public static void main(String[] args) throws EntityNotFoundException {
  7.         DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
  8.        
  9.         Entity entity = new Entity("monster", 566);
  10.         entity.setProperty("health", 100);
  11.         entity.setProperty("name", "Vasya");
  12.        
  13.         datastore.put(entity);
  14.        
  15.         entity = datastore.get(KeyFactory.createKey("monster", 566));
  16.         int health = (Integer) entity.getProperty("health");
  17.         String name = (String) entity.getProperty("name");
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement