FileDocCategorySizeDatePackage
NamedQuery.javaAPI DocGlassfish v2 API3359Fri May 04 22:34:06 BST 2007javax.persistence

NamedQuery

public class NamedQuery
Is used to specify a named query in the Java Persistence query language, which is a static query expressed in metadata. Query names are scoped to the persistence unit.

The following is an example of the definition of a named query in the Java Persistence query language:

@NamedQuery(
name="findAllCustomersWithName",
query="SELECT c FROM Customer c WHERE c.name LIKE :custName"
)

The following is an example of the use of a named query:

@PersistenceContext
public EntityManager em;
...
customers = em.createNamedQuery("findAllCustomersWithName")
.setParameter("custName", "Smith")
.getResultList();
since
Java Persistence 1.0

Fields Summary
Constructors Summary
Methods Summary
javax.persistence.QueryHint[]hints()
Vendor-specific query hints

java.lang.Stringname()
Refers to the query when using the {@link EntityManager} methods that create query objects.

java.lang.Stringquery()
The query string in the Java Persistence query language