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

CDO/Hibernate Store/HQL

< CDO‎ | Hibernate Store
Revision as of 12:02, 21 January 2010 by Mtaal.springsite.com (Talk | contribs) (New page: __TOC__ The CDO Hibernate Store supports HQL as the query language. For a detailed description the HQL syntax visit the documentation [http://docs.jboss.org/hiber...)

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


The CDO Hibernate Store supports HQL as the query language. For a detailed description the HQL syntax visit the documentation here.

This page shows examples of different HQL queries to give a feel for what the possibilities are to use HQL directly from the client. As far as is known there are no limits in using HQL on the client.

Note that HQL is supported not the Hibernate Criteria api.

Example projects

The HQL queries discussed here are available in the example project: org.eclipse.emf.cdo.examples.hibernate.client, in the HibernateQueryTest class.

The model which is used here is available as an example project: org.eclipse.emf.cdo.examples.company.

The download & install page describes how/where to find these example projects.

A simple query

Let's start with a simple query to also introduce the client side query api. The following code snippet shows how to retrieve all products from the backend:

    CDOSession session = openSession();
    CDOTransaction transaction = session.openTransaction();
 
    {
      CDOQuery cdoQuery = transaction.createQuery("hql", "from Product"); //$NON-NLS-1$  //$NON-NLS-2$
      final List<Product> products = cdoQuery.getResult(Product.class);

Wikis: CDO | Net4j | EMF | Eclipse

Back to the top