Revision: 33925
Updated Code
at October 15, 2010 00:47 by phantomas
Updated Code
PersistenceManager pm = JDOHelper.getPersistenceManagerFactory("transactions-optional").getPersistenceManager(); String keyAsString = "key of object"; Key objectDbKey = KeyFactory.createKey(MyDbObject.class.getSimpleName(), keyAsString); DbObject_Device object = null; try{ object = pm.getObjectById(MyDbObject.class, objectDbKey); } if(object != null){ // Object was present in database } else{ // .. not present object = new DbObject(); } // change object values here pm.makePersistent(object ); pm.close();
Revision: 33924
Updated Code
at October 15, 2010 00:37 by phantomas
Updated Code
PersistenceManager pm = JDOHelper.getPersistenceManagerFactory("transactions-optional").getPersistenceManager(); String keyAsString = "key of object"; Key objectDbKey = KeyFactory.createKey(MyDbObject.class.getSimpleName(), keyAsString); DbObject_Device object = null; try{ object = pm.getObjectById(MyDbObject.class, keyAsString); } if(object != null){ // Object was present in database } else{ // .. not present object = new DbObject(); } // change object values here pm.makePersistent(object ); pm.close();
Revision: 33923
Updated Code
at October 15, 2010 00:26 by phantomas
Updated Code
PersistenceManager pm = JDOHelper.getPersistenceManagerFactory("transactions-optional").getPersistenceManager(); String keyAsString = "key of object"; Key objectDbKey = KeyFactory.createKey(MyDbObject.class.getSimpleName(), keyAsString); DbObject_Device object = null; try{ object = pm.getObjectById(MyDbObject.class, keyAsString); } if(object != null){ // Object was present in database } else{ // .. not present }
Revision: 33922
Updated Code
at October 15, 2010 00:24 by phantomas
Updated Code
String keyAsString = "key of object"; Key objectDbKey = KeyFactory.createKey(MyDbObject.class.getSimpleName(), keyAsString); DbObject_Device object = null; try{ object = pm.getObjectById(MyDbObject.class, keyAsString); } if(object != null){ // Object was present in database } else{ // .. not present }
Revision: 33921
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 15, 2010 00:20 by phantomas
Initial Code
String keyAsString = "key of object"; Key objectDbKey = KeyFactory.createKey(MyDbObject.class.getSimpleName(), keyAsString); DbObject_Device object = pm.getObjectById(MyDbObject.class, keyAsString); if(object != null){ // Object was present in database } else{ // .. not present }
Initial URL
Initial Description
import com.google.appengine.api.datastore.Key;\\\\\\\\\\\\\\\\r\\\\\\\\\\\\\\\\nimport com.google.appengine.api.datastore.KeyFactory;
Initial Title
Appengine: Check if object is present in database
Initial Tags
Initial Language
Java