java - Get entity group count always return 0 -
After this I try to check it in my local dev environment (unit test), unfortunately unit group count is always returned Comes to 0:
Datastore service DS = Datastoreservicefirefactor.getdataStoreService (); MemcacheService memcacheService = MemcacheServiceFactory.getMemcacheService (); Unit entity1 = new unit ("simple"); Key key1 = ds.put (entity1); Main Unit Group = Institutions.Content Entity Group (Key 1); // 1 should be printed, but 0 show AntitigroupCount (DS, Memkseva, Antiguakki); Unit unit 2 = new unit ("simple", key 1); Key key2 = ds.put (entity2); // 2 should be printed, but still show 0 group of Entity Group Groups (DS, MmaxService, Antiguakki); For quick reference, copied from
:
// A simple class square for tracking compatible unit groups EntityGroupCount tool serialZabel {long Edition; // The version of the entity group whose count we are computing the integer; EntityGroupCount (long version, int count) {this.version = version; This.count = count; }} // Display count of institutions in a unit group, in which continuous caching is shown in the zero-show Entity Group Group (Datastore Service DS, Memkets Service Cash, Printer Writer, Key Entity Group) {EntityGroupCount such as account = (EntityGroupCount) cache.get (entityGroupKey) ; If (for example calculation! = Null & amp; example; count.version == getEntityGroupVersion (DS, blank, entity aggregator)) // // Cached value matches current entity group version, use that author . Println (egCountCount + "entities (cached)"); } Else {// In fact, entities need to count the use of a corresponding number / and transaction group unit to obtain. Transaction tx = dbbt Prepared PP = ds.prepare (tx, new query (unit group)); Int count = pq.countEntities (FetchOptions.Builder.withLimit (5000)); Cache.poot (integroup group, new unit group count (getEntityGroupVersion (DS, Tx, Entint Group, count)); tx.rollback (); Author. Print (number + "entities");}}
entities .createEntityGroupKey ( ) The method is being said twice as a result of nesting.
Change both incidents of Show Entity GroupCount (DS, MMCService, Entity GroupCa);
to
showEntityGroupCount (DS, Magsayservice Service, Key 1);
and correct numbers appear (Anyway the development environment In).
Comments
Post a Comment