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

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

  1. In the DbXplorer view, navigate to the DbXaminer tab and select click the HQL Editor tab (at the bottom of the tab). Then navigate to the workshop-hibernate-tutorial web application.

  2. 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.
  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:Tthe properties are prefixed by an alias p for Product entity.

  5. Enter from (You can use code completion for the 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 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.

  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:


Still need help? Post a question on the Workshop newsgroup.

 

Skip navigation bar   Back to Top