Reputation: 32680
When I create an Entity class from a database in NetBeans, it gives me the option to create Named Queries from persistent fields. Accordingly, I see these named queries listed at the top of my Entity class.
What exactly are these queries, and how can I utilize/"call" them?
I'm aware this question is more general than is preferred on SO, so I'm happy to accept a link to a tutorial that answers these questions, but I've been unable to find one myself.
Upvotes: 1
Views: 2604
Reputation: 42060
See
If you have:
@NamedQuery(name="Country.findAll", query="SELECT c FROM Country c")
public class Country {
...
}
Use with:
TypedQuery<Country> query = em.createNamedQuery("Country.findAll",Country.class);
List<Country> results = query.getResultList();
See also:
Upvotes: 3