Skip Headers
Dali Java Persistence Tools User Guide
Release 3.2
Release 3.2
  PDF
PDF
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Specifying entity inheritance
 
Next
Mapping an entity
 

Creating queries

Named queries improve application performance because they are prepared once and they (and all of their associated supporting objects) can be efficiently reused thereafter, making them well suited for complex and frequently executed operations. Named queries use the JPA query language for portable execution on any underlying database; named native queries use the SQL language native to the underlying database.

Use this procedure to add @NamedQuery and @NamedNativeQuery annotations to the entity.

To create a named query:

  1. Select the entity in the Project Explorer.

  2. In the JPA Details view, expand the Queries area.

    Figure 3-45 JPA Details, Queries Tab


  3. Click Add to add a new query. The Add Query dialog appears

    Figure 3-46 Add Query Dialog

    Add Query dialog
  4. Enter the name of the query, select the query type (Named Query or Named Native Query), and click OK. The Queries area expands to show additional fields.

    Figure 3-47 JPA Details, Queries Tab


  5. Enter the query in the Query field.

  6. Complete the rest of the field on the Queries page.

  7. To add a Query hint, click Add. Enter the Name and Value of the hint.

Related reference