Step 6. Using HQL Editor
In this step, we will review of HQL Editor. The HQL Editor provides the facility to define and execute an HQL query.
- In the DbXaminer view,
select the HQL Editor tab (at the bottom of the view). (If
the DbXaminer view is closed, you can open it by right-clicking
on SalesDBConnection in the DbXplorer and
selecting Show in DbXaminer.)
- Navigate to the workshop-hibernate-tutorial web
application as shown below.

- When defining an HQL query in the HQL Editor, Workshop
provides code completion for HQL keywords and the persistent entities
by pressing CTRL+SPACE. Here, we will define an HQL SELECT
query using the code completion facility. In HQL Editor, enter S and
press CTRL+SPACE. It displays a list of HQL keywords starting
with letter S.

- Select the keyword select keyword.
- Using the same code completion technique, enter the following query:
select p.productid, p.code, p.name from Product as p
- Now, we have defined a HQL SELECT query. You can execute them by either
clicking the Execute Query button or by using the hotkey, CTRL+ENTER.

- Add a WHERE clause to the query to get products having code starting with prefix AB. You can either use code completion or write manually. Run the query to get products data.

- Click the Generated SQL tab in HQL Editor. It displays native SQL built based on the defined HQL query.

Click one of the following arrows to navigate through the tutorial:
Still need help? Post a question on the Workshop
newsgroup.