Google App Engine list type Query

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.