A major feature of Google App Engine is the added default support for listtype. In addition, we can query through listtype.
Unit test code:
@ Test
Public void testlistquery (){
Datastoreservice datasvc = datastoreservicefactory. getdatastoreservice ();
Entity en = new entity ("testlist ");
List <string> listprop = arrays. aslist ("T1", "T2", "T3", "T4 ");
En. setproperty ("list", listprop );
Datasvc. Put (en );
Entity EN2 = new entity ("testlist ");
List <string> listprop2 = arrays. aslist ("T1", "T3", "T5", "T7 ");
En2.setproperty ("list", listprop2 );
Datasvc. Put (EN2 );
// List equals sign items
Query q = new query ("testlist ");
Q. addfilter ("list", filteroperator. Equal, "T1 ");
Q. addfilter ("list", filteroperator. Equal, "T3 ");
List ls = datasvc. Prepare (Q). aslist (fetchoptions. Builder. withdefaults ());
Assertequals (2, ls. Size ());
// List in list
Query q2 = new query ("testlist ");
Q2.addfilter ("list", filteroperator. In, listprop2 );
List ls2 = datasvc. Prepare (Q2). aslist (fetchoptions. Builder. withdefaults ());
Assertequals (2, ls2.size ());
}
1. List equals one: you only need to map any item in the list to the value of one. (list items only support the most basic types)
2. List in list: it is equivalent to the query parameter list and the Value List. If any one of them is equal (equals is true), the matching is considered. Therefore, 2 is returned.