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.
CDO/Hibernate Store/HQL
Contents
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);