Dali Java Persistence Tools User Guide Release 3.2 Release 3.2 |
|
Specifying entity inheritance |
Mapping an entity |
Home > User Guide > Tasks > 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:
Select the entity in the Project Explorer.
In the JPA Details view, expand the Queries area.
Click Add to add a new query. The Add Query dialog appears
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.
Enter the query in the Query field.
Complete the rest of the field on the Queries page.
To add a Query hint, click Add. Enter the Name and Value of the hint.
Related reference