@Target(value=TYPE) @Retention(value=RUNTIME) public @interface NamedQuery
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();
Modifier and Type | Required Element and Description |
---|---|
String |
query
The query string in the Java Persistence query language
|
Modifier and Type | Optional Element and Description |
---|---|
QueryHint[] |
hints
Vendor-specific query hints
|
String |
name
Refers to the query when using the
EntityManager
methods that create query objects. |
public abstract String query
public abstract String name
EntityManager
methods that create query objects.public abstract QueryHint[] hints
Copyright © 2013. All Rights Reserved.