-
Notifications
You must be signed in to change notification settings - Fork 18
Semantic Object Query Language
Martin Ledvinka edited this page Jul 28, 2023
·
8 revisions
The Semantic Object Query Language (SOQL) is an object query language analogous to JPQL (or HQL) designed for JOPA. Its main purpose is to simplify creation of queries over the object model managed by JOPA. SOQL queries are translated into SPARQL based on the metamodel and executed in a similar manner to the current support for SPARQL in JOPA.
The goal is to support as many features of JPQL as possible, but taking into account the specifics of SPARQL and ontologies.
-
SELECT,DISTINCT - Join by property path (
p.phone.number) -
LIKE,AND,OR,NOT, (since 0.20.0)IN, (since 1.1.0)MEMBER OF -
ORDER BY,GROUP BY -
COUNT- on entity result, e.g.SELECT COUNT(p) FROM Person p - Comparison operators -
>,<,>=,<=,=,<>(alternatively!=) - (Since 0.22.0) Functions on strings -
UPPER,LOWER,LENGTH - (Since 0.22.0) Functions on numbers -
ABS,CEIL,FLOOR - (Since 0.22.0) Selection by identifier
- (Since 1.1.0) Language tag extraction function
LANG
Simple examples:
SELECT p FROM Person pSELECT p FROM Person p WHERE p.username = :usernameSELECT p FROM Person p WHERE NOT p.role = :roleSELECT p FROM Person p WHERE p.username LIKE :usernameSELECT p FROM Person p WHERE p.phone.number = :phoneNumberSELECT p FROM Person p WHERE p.age > :age ORDER BY p.age DESCSELECT p FROM Person p WHERE p.username IN :authorizedUsersSELECT p FROM Person p WHERE :adminType MEMBER OF p.typesSELECT t FROM Term t WHERE LANG(t.label) = :uiLanguage
See SoqlQueryParserTest for more examples.
The following features are not implemented, yet:
- Parentheses in the
WHEREclause -
ASK,OPTIONAL - Aggregation functions besides
count(furthermore,countworks only for entities) - Complex joins
- Projection of multiple entities or entity attributes -> currently, only an entity (or its count) can be projected from the query
- Inner select