Previous Next vertical dots separating previous/next from contents/index/pdf

7. Using HQL Editor

In this step, we will take an overview of HQL Editor. The HQL Editor provides facility to define and execute an HQL query.

7.1. Using HQL Editor

  1. In DbXaminer, go to the HQL Editor tab and click the button to choose the Workshop-Hibernate-Tutorial web application.

  2. When defining an HQL query in HQL Editor, Workshop Studio 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.
  3. Select the keyword select keyword.
  4. Enter space and specify comma separated properties of Product object to get the data i.e. p.productid, p.code, p.name as shown below. Note: the properties are prefixed by an alias p for Product entity.

  5. Enter from (You can use code completion for from keyword) and space.
  6. Press CTRL+SPACE to get a list of persistent entities and select the Product object.

  7. Enter space and specify an alias p for Product entity.
  8. Now, we have defined the HQL SELECT query. You can execute them by either clicking the Execute Query button or by using the hotkey, CTRL+ENTER.

  9. Add HQL 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.

  10. 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:

 

Skip navigation bar   Back to Top