EJBQLQuery has been edited by Andrus Adamchik (Jun 11, 2007).

(View changes)


(available since 3.0 in both classic and JPA modes; as of June 2007 only a subset of EJBQL syntax is supported)

EJBQL is an object query language that is not unlike SQL, only it operates in terms of the Java object model. In fact "EJB" in its name is entirely misleading - the language is applicable in the non-"enterprise" environments just as well. Standard EJBQL syntax is specified in the JPA specification, still Cayenne supports it in a classic mode, and no JPA runtime is required to execute such queries. This chapter deals specifically with classic mode operation.

EJBQL Syntax

Details of the syntax are available in various JPA literature. Here is an example of an EJBQL query:

select p from Painting p WHERE p.estimatedPrice > 3000

Visually it looks like SQL, only instead of tables, object entities are used; and instead of columns and joins, path expressions are used (not unlike Cayenne path expressions).

(TODO: would be nice to fill in more examples)

Creating an EJBQLQuery

Creating an EJBQLQuery is simple - just pass a valid EJBQL string to the constructor:

EJBQLQuery query = new EJBQLQuery("select a FROM Artist a");

Further you can use the query object the same way as any other Cayenne query to select objects or to modify the database.

As of June 2007, only selecting EJBQL syntax is supported; there are various other limitations

Select objects:

List artists = context.performQuery(query);

EJBQL vs. SelectQuery


Powered by Atlassian Confluence (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request

Unsubscribe or edit your notifications preferences