Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
These BIFs

Table of Contents


 

 

Selector Built-in Functions

These functions are available via the object's namespace, e.g. Person:{function}.

They can be used to

build up a complex selector for reading

read sets of data from the persistence layer.

These BIFs are accessed via the pseudo unit with the same name as the object that is being queried eg. “Person” or “Car”
TypeDescription
allSimple all
equalsEquality
emptyDetermine whether a variable is empty
betweenSelect a range of data between two values
lessThanOrEqual
Less or equals check
lessThanCheck if value is less than the value being compared to
greaterThanCheck if value is greater than the value being compared to
attributeInAttribute In
relationshipInRelationship In
containsCheck is collection has element(s)
beginsWithBegin with
endsWithEnd with
notEqualsNot Equals
notEmptyNot empty
notBetweenNot between the data or elements
notContainsCollection does not contain element(s)
notBeginWithNot begin with
notEndsWithCheck if value does not end with value being compared to
notAttributeInAttribute not in the given domain
notRelationshipInUse to check for relationship
unionUnion
diffUse to check for differences
intersectIntersect
andAnd (in most cases, use this rather than intersect)

These BIFs perform operations on single persistent entities. They are accessed via a method call on a variable holding an object instance or on the pseudo unit with the same name as the object that the method is being performed on

 

 

 

 

 

The final four in the table below (uniondiffintersect, and and) can be used to build up a complex selector using a combination of other selector BIFs as parameters. The other selectors all take an object's attribute as first parameter, and one or more values as the next parameter(s).



FunctionSyntaxDescriptionExample
allObj:all()Returns all records from the table.Person[] plist = Person:all();
equalsObj:equals(a,b)

Returns records with value of a equal to b.

Person[] plist = Person:equals(deleted, false);
notEqualsObj:notEquals(a,b)Returns records with value of a not equal to b.Person[] plist = Person:notEquals(deleted, true);
emptyObj:empty(a)Returns records with a equal to null.Person[] plist = Person:empty(mobileNum);
notEmptyObj:notEmpty(a)Returns records with a not equal to null.Person[] plist = Person:notEmpty(mobileNum);
betweenObj:between(a,x,y)Returns records with value of a within the range of values between x and y.Person[] plist = Person:between(dob, date1, date2);
notBetweenObj:notBetween(a,x,y)Returns records with value of a not within the range of values between x and y.Person[] plist = Person:notBetween(dob, date1, date2);
lessThanOrEqual
Obj:lessThanOrEqual(a,b)Returns records with value of a less than or equal to b.Person[] plist = Person:lessThanOrEqual(age, num);
lessThanObj:lessThan(a,b)Returns records with value of a less than b.Person[] plist = Person:lessThan(age, num);
greaterThanObj:greaterThan(a,b)Returns records with value of a greater than b.Person[] plist = Person:greaterThan(age, num);
attributeInObj:attributeIn(a,b)Returns records with value of a matching any of the values b (replace b with a list of values of the same type as a).Person[] plist = Person:attributeIn(state, state_list);
notAttributeInObj:notAttributeIn(a,b)Returns records with value of a not matching any of the values b (replace b with a list of values of the same type as a).Person[] plist = Person:notAttributeIn(state, state_list);
relationshipInObj:relationshipIn(a,b)Returns records with a relationship/link between a and b, with attribute a being annotated as @OneToMany, @ManyToOne, etc. and b a persistent object instance. Attribute a can be likened to a foreign key.Person[] plist = Person:relationshipIn(reportsTo, person);
notRelationshipInObj:notRelationshipIn(a,b)Returns records without a relationship/link between a and b, with attribute a being annotated as  @OneToMany, @ManyToOne, etc. and b a persistent object instance. Attribute a can be likened to a foreign key.Person[] plist = Person:notRelationshipIn(reportsTo, person);
containsObj:contains(a,b)Returns records with substring b found anywhere within value of a.Person[] plist = Person:contains(name, "a");
beginsWithObj:beginsWith(a,b)Returns records with substring b found at the beginning of the value of a.Person[] plist = Person:beginsWith(name, "a");
endsWithObj:endsWith(a,b)Returns records with substring b found at the end of the value of a.Person[] plist = Person:endsWith(name, "a");
notContainsObj:notContains(a,b)Returns records with substring b found nowhere within value of a.Person[] plist = Person:notContains(name, "a");
notBeginWithObj:notBeginWith(a,b)Returns records with substring b not found at the beginning of the value of a.Person[] plist = Person:notBeginWith(name, "a");
notEndsWithObj:notEndsWith(a,b)Returns records with substring b not found at the end of the value of a.Person[] plist = Person:notEndsWith(name, "a");
unionObj:union(selector1(a,b), selector2(x,y))

Combines the results of two or more selectors. Does not return the same record twice.

Person[] plist = Person:union(equals(rating, "good"), equals(rating, "excellent"));
diffObj:diff(selector1(a,b), selector2(x,y))Compares the results of two or more selectors and returns only the difference.Person[] plist = Person:diff(equals(), equals());
intersectObj:intersect(selector1(a,b), selector2(x,y))Returns records for which all the selectors are true.Person[] plist = Person:intersect(equals(deleted, false), equals(active, true));
andObj:and(selector1(a,b), selector2(x,y))Returns records for which all the selectors are true.Person[] plist = Person:and(equals(deleted, false), equals(active, true));





Data Subsets

Having populated a collection with a selector BIF, you can further refine your selection by assigning a subset of said collection to a new collection by using the select BIF. This BIF is available via the collection variable and takes one or a combination of the above selector BIFs as parameter. See the Collections for details.




Executing SQL

Helium provides functionality to execute SQL natively from the DSL. Details can be found here.




Excerpt
hiddentrue

all, equals, notEquals, etc. | select | sql