Db4o Learning (5)-soda

Source: Internet
Author: User

1. Soda query Graphs

---- A graph data structure

Find all persons whose names are "Lincoln"

 

2. Soda keywords

(1) query keywords

(2) Constraint keywords

 

3. query example

(1) query all

 
DB = db4o. openfile ("Customer. yap"); Query = dB. Query (); query. constrain (customer.Class); List <customer> rsw.query.exe cute ();For(Customer C: RS) {system. Out. println (C. getname ());}
 
 
 
(2) conditional Query
Query query = dB. Query ();Query. constrain (customer.Class); // Class-level constraintsQuery. Descend ("Name"). Constrain ("Customer2"); // Field-level constraintsList <customer> rsw.query.exe cute ();

 

(3) Use keywords

 
DB = db4o. openfile ("Customer. yap"); Query = dB. Query (); query. constrain (customer.Class); Query. Descend ("Name"). Constrain ("Customer2"). Not ();List <customer> rsw.query.exe cute ();
 
 
 
(4) Compound Conditions
 
 
 
And usage:
Query query = dB. Query (); query. constrain (customer.Class);Constraint firstconstr = query. Descend ("Phonenumber"). Constrain ("Phone2"); Query. Descend ("Name"). Constrain ("Customer2"). And (firstconstr );List <customer> rsw.query.exe cute ();
 
It is equivalent:
 
Query query = dB. Query (); query. constrain (customer.Class); Query. Descend ("Name"). Constrain ("Customer2"); Query. Descend ("Phonenumber"). Constrain ("Phone2"); List <customer> rsw.query.exe cute ();
 
Query query = dB. Query ();
 
 
Or usage: Query. constrain (customer.Class);Constraint firstconstr = query. Descend ("Phonenumber"). Constrain ("Phone3"); Query. Descend ("Name"). Constrain ("Customer2"). Or (firstconstr );List <customer> rsw.query.exe cute ();
 
 
 
(5) Greater/smaller
 
Query query = dB. Query (); query. constrain (person.Class); Query. Descend ("_ Age"). Constrain (80). Greater (); objectset resultappsquery.exe cute ();

 

(6) Range Query

Query query = dB. Query (); query. constrain (person.Class); Constraint firstconstr = query. Descend ("_ Age"). Constrain (60). Greater (); query. Descend ("_ Age"). Constrain (80). Smaller (). And (firstconstr );

 

(7) fuzzy search

 
Query query = dB. Query (); query. constrain (person.Class); Query. Descend ("_ Name"). Constrain ("Ma"). Like ();// Also works with "Ma"Objectset result = query.exe cute ();

 

(8) query null values

Query query = dB. Query (); query. constrain (person.Class); Query. Descend ("Age"). Constrain (0 );// Field has been setObjectset resultappsquery.exe cute ();

 

(9) sorting results

 
// JavaQuery query = dB. Query (); query. constrain (person.Class); Query. Descend ("_ Name"). Orderascending ();// The list shocould start with the lowestObjectset resultappsquery.exe cute ();

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.