What is an Object Query Language?
An Object Query Language (OQL) is usually an expression language combined with an API to help users query a set of objects, navigate through an object graph, and get or set values on those objects. There are lots of different implementations of Object Query Languages, most of them tied to a specific technology (EJB-QL and JDOQL, for example).
Does Prevayler have an Object Query Language?
Implementing a Prevayler-specific object query language was discussed several times on the mailing lists, but was ruled out of scope for the project. This decision was backed by the need to free users and developers of Prevayler to choose whatever querying mechanism suits their needs best, instead of requiring them to adapt to a specific query model.
What Object Query Languages are available?
Fortunately, a handful of Object Query Languages are available, which you can pick and choose to best fit your needs. Among the best generic ones we have found so far are JXPath and OGNL. Jaxen might also be interesting to look at. Also, some scripting languages, like Groovy can be used.
How Object Query Languages speed up Prevayler application development?
Using an OQL is a nice way to avoid the baptism problem, and it's also an easy and powerful way to allow ad-hoc querying on prevalent systems.
To better demonstrate the flexibility offered by an OQL, this is the Java code to query all the street addresses from employees located in the UK office:
And below is a table with the same example using different languages:
Language |
Example query |
|---|---|
|
|
|
|
|

2 Comments
Hide/Show CommentsApr 13, 2004
James Strachan
FWIW using groovy for the query language would look like this
Its easy to introspect groovy's AST to reuse any indices you might have. We use this technique to turn predicate closures into SQL...
http://cvs.groovy.codehaus.org/viewcvs.cgi/groovy/groovy-core/src/test/groovy/sql/PersonTest.groovy?rev=ROOT&view=auto
Apr 13, 2004
cv
Looks pretty sweet, James. I've updated the page to mention it. Thanks!