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

   JPA Details, Queries Tab

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

   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.

   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

- Queries