@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();
public abstract String query
public abstract String name
EntityManager
methods that create query objects.public abstract QueryHint[] hints
Copyright © 2016. All rights reserved.