本文整理了Java中com.google.appengine.api.datastore.Entity.getKey()
方法的一些代码示例,展示了Entity.getKey()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.getKey()
方法的具体详情如下:
包路径:com.google.appengine.api.datastore.Entity
类名称:Entity
方法名:getKey
暂无
代码示例来源:origin: stackoverflow.com
Query query = new Query(Entities.KIND_METADATA_KIND);
DatastoreService datastoreService = DatastoreServiceFactory.getDatastoreService();
Iterable<Entity> entityIterable = datastoreService.prepare(query).asIterable();
for(Entity entity : entityIterable) {
System.out.println("Entity kind: " + entity.getKey().getName());
}
代码示例来源:origin: com.google.appengine.orm/datanucleus-appengine
/**
* @throws java.util.NoSuchElementException if there are no more elements to resolve.
*/
void resolveNext() {
Entity entity = lazyEntityIterator.next();
resolvedPojos.add(entityTransformer.apply(entity));
if (resultKeys != null) {
resultKeys.add(entity.getKey());
}
}
代码示例来源:origin: org.vesalainen.dsql/dsql
@Override
public void delete(Entity row)
{
datastore.delete(row.getKey());
}
代码示例来源:origin: com.google.appengine.orm/datanucleus-appengine
void addPutEntities(List<Entity> entities) {
for (Entity entity : entities) {
// Make a copy in case someone changes
// the provided entity after we add it to our cache.
putEntities.put(entity.getKey(), makeCopy(entity));
}
}
代码示例来源:origin: org.vesalainen.dsql/dsql
@Override
public void delete(Collection<Entity> rows)
{
List<Key> keys = new ArrayList<>();
for (Entity entity : rows)
{
keys.add(entity.getKey());
}
datastore.delete(keys);
}
代码示例来源:origin: com.google.appengine.orm/datanucleus-appengine
public Object fetchObjectField(int fieldNumber) {
AbstractMemberMetaData ammd = cmd.getMetaDataForManagedMemberAtAbsolutePosition(fieldNumber);
if (isPK(fieldNumber)) {
if (ammd.getType().equals(Key.class)) {
// If this is a pk field, transform the Key into its String representation.
return datastoreEntity.getKey();
} else if (ammd.getType().equals(Long.class)) {
return datastoreEntity.getKey().getId();
}
}
return null;
}
代码示例来源:origin: stackoverflow.com
private static Key getKeyForCity(String uniqueID, String city) {
Key ancestorKey = KeyFactory.createKey("User", uniqueID);
Query query = new Query("Trip", ancestorKey);
query.addFilter("city", FilterOperator.EQUAL, city);
Entity trip = datastore.prepare(query).asSingleEntity();
return trip.getKey();
}
代码示例来源:origin: stackoverflow.com
Datastore datastore = DatastoreOptions.getDefaultInstance().getService();
// ...
Entity old = null /* some value */;
Key oldKey = old.getKey();
KeyFactory kf = datastore.newKeyFactory().setKind(oldKey.getKind());
Entity newEntity = Entity.newBuilder(old)
.setKey(kf.newKey(oldKey.getName()))
.build();
datastore.delete(oldKey);
datastore.put(newEntity);
代码示例来源:origin: feroult/yawp
@Override
public List<String> listNamespaces() {
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
Query query = new Query("__namespace__").setKeysOnly();
PreparedQuery pq = ds.prepare(query);
List<String> namespaces = new ArrayList<>();
for (Entity entity : pq.asIterable()) {
namespaces.add(entity.getKey().getName());
}
return namespaces;
}
代码示例来源:origin: org.vesalainen.dsql/dsql
private void refresh()
{
model.clear();
entityList = engine.getAll(storedStatementsKind);
for (Entity entity : entityList)
{
model.add(entity.getKey().getName());
}
}
private void init()
代码示例来源:origin: org.eiichiro.acidhouse/acidhouse-appengine
/**
* Translates Google App Engine Datastore entity to Acid House {@code Lock}
* entity.
*
* @param entity oogle App Engine Datastore entity.
* @return Acid House {@code Lock} entity.
*/
public static Lock toLock(Entity entity) {
return new Lock(entity.getKey().getName(),
(String) entity.getProperty(TRANSACTION_PROPERTY),
(Date) entity.getProperty(TIMESTAMP_PROPERTY));
}
代码示例来源:origin: com.googlecode.cedar-common/objectify
@Override
public T toObject(Entity ent, Objectify ofy)
{
T pojo = TypeUtils.newInstance(this.entityClassConstructor);
// This will set the id and parent fields as appropriate.
this.setKey(pojo, ent.getKey());
this.transmog.load(ent, pojo);
// If there are any @PostLoad methods, call them
this.invokeLifecycleCallbacks(this.postLoadMethods, pojo, ent, ofy);
return pojo;
}
代码示例来源:origin: GoogleCloudPlatform/appengine-tck
protected void clearData(String kind, Key parentKey, int waitMilliSec) {
List<Key> eList = new ArrayList<>();
Query query = new Query(kind, parentKey);
for (Entity readRec : service.prepare(query).asIterable()) {
eList.add(readRec.getKey());
}
if (eList.size() > 0) {
service.delete(eList);
sync(waitMilliSec);
}
}
代码示例来源:origin: GoogleCloudPlatform/appengine-tck
@After
@Override
public void tearDown() {
for (Set<Entity> entities2 : entities) {
for (Entity entity : entities2) {
service.delete(entity.getKey());
}
}
super.tearDown();
}
代码示例来源:origin: GoogleCloudPlatform/appengine-tck
@Test
public void testSortingByIntegerProperty() throws Exception {
String methodName = "testSortingByIntegerProperty";
Entity parent = createTestEntityWithUniqueMethodNameKey(QUERY_SORTING_ENTITY, methodName);
Key key = parent.getKey();
Entity two = storeTestEntityWithSingleProperty(key, 2);
Entity one = storeTestEntityWithSingleProperty(key, 1);
Entity three = storeTestEntityWithSingleProperty(key, 3);
assertList(whenSortingByTheSingleProperty(ASCENDING, key), containsResultsInOrder(one, two, three));
assertList(whenSortingByTheSingleProperty(DESCENDING, key), containsResultsInOrder(three, two, one));
service.delete(two.getKey(), one.getKey(), three.getKey());
}
代码示例来源:origin: GoogleCloudPlatform/appengine-tck
@Test
public void testSortingByFloatProperty() throws Exception {
String methodName = "testSortingByFloatProperty";
Entity parent = createTestEntityWithUniqueMethodNameKey(QUERY_SORTING_ENTITY, methodName);
Key key = parent.getKey();
Entity thirty = storeTestEntityWithSingleProperty(key, 30f);
Entity two = storeTestEntityWithSingleProperty(key, 2f);
Entity hundred = storeTestEntityWithSingleProperty(key, 100f);
assertList(whenSortingByTheSingleProperty(ASCENDING, key), containsResultsInOrder(two, thirty, hundred));
assertList(whenSortingByTheSingleProperty(DESCENDING, key), containsResultsInOrder(hundred, thirty, two));
service.delete(thirty.getKey(), two.getKey(), hundred.getKey());
}
代码示例来源:origin: GoogleCloudPlatform/appengine-tck
@Test
public void testIntegerPropertySortingIsNotLexicographic() throws Exception {
String methodName = "testIntegerPropertySortingIsNotLexicographic";
Entity parent = createTestEntityWithUniqueMethodNameKey(QUERY_SORTING_ENTITY, methodName);
Key key = parent.getKey();
Entity ten = storeTestEntityWithSingleProperty(key, 10);
Entity five = storeTestEntityWithSingleProperty(key, 5);
Query query = createQuery().setAncestor(key).addSort(SINGLE_PROPERTY_NAME, ASCENDING);
List<Entity> results = service.prepare(query).asList(withDefaults());
assertTrue(results.indexOf(five) < results.indexOf(ten)); // if sorting were lexicographic, "10" would come before "5"
service.delete(ten.getKey(), five.getKey());
}
代码示例来源:origin: GoogleCloudPlatform/appengine-tck
protected void assertEntityNotInRange(Entity entity, KeyRange range) {
// allocated key should not be re-used.
Assert.assertTrue(entity.getKey().getId() > range.getEnd().getId() ||
entity.getKey().getId() < range.getStart().getId());
}
代码示例来源:origin: GoogleCloudPlatform/appengine-tck
@Test
public void queriesDontReturnDeletedEntities() throws Exception {
String methodName = "queriesDontReturnDeletedEntities";
Entity entity = createTestEntityWithUniqueMethodNameKey(SMOKE_TEST_ENTITY, methodName);
Key key = entity.getKey();
service.put(entity);
service.delete(key);
List<Entity> entities = service.prepare(new Query(SMOKE_TEST_ENTITY).setAncestor(key))
.asList(FetchOptions.Builder.withDefaults());
assertEquals(0, entities.size());
}
代码示例来源:origin: GoogleCloudPlatform/appengine-tck
public void purgeTestRunRecords() {
DatastoreService datastoreService = DatastoreServiceFactory. getDatastoreService();
FilterPredicate testRunFilter = new FilterPredicate(TEST_RUN_ID, FilterOperator.EQUAL, testRunId);
Query query = new Query(entityName).setFilter(testRunFilter).setKeysOnly();
for (Entity readRec : datastoreService.prepare(query).asIterable()) {
datastoreService.delete(readRec.getKey());
}
}
内容来源于网络,如有侵权,请联系作者删除!