Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

EclipseLink/Examples/JPA/DatabaseQuery

< EclipseLink‎ | Examples‎ | JPA
Revision as of 14:09, 12 March 2009 by James.sutherland.oracle.com (Talk | contribs) (New page: In addition to JPQL, EclipseLink defines a rich DatabaseQuery and Expression criteria API. See: * [http://www.eclipse.org/eclipselink/api/1.1/org/eclipse/persistence/queries/package-frame...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

In addition to JPQL, EclipseLink defines a rich DatabaseQuery and Expression criteria API.

See:

Using JpaEntityManager createQuery() API

ExpressionBuilder builder = new ExpressionBuilder();
ReadAllQuery databaseQuery = new ReadAllQuery(Employee.class, builder);
databaseQuery.setSelectionCriteria(builder.get("firstName").like("B%"));
databaseQuery.addOrdering(builder.get("firstName").toUpperCase());
 
Query query = ((JpaEntityManager)entityManager.getDelegate()).createQuery(databaseQuery);
List result = query.getResultList();

This JpaEntityManager API was added in EclipseLink 1.1, in EclipseLink 1.0, the JpaQuery method setDatabaseQuery() could be used.

Back to the top