8.6. Query Factory

public Query createQuery (String query);

Query objects are used to find entities matching certain criteria. The createQuery method creates a query using the given EJB Query Language (JPQL) string. See Chapter 10, JPA Query for details.

public Query createNamedQuery (String name);

This method retrieves a query defined in metadata by name. The returned Query instance is initialized with the information declared in metadata. For more information on named queries, read Section 10.1.9, “Named Queries”.

public Query createNativeQuery (String sql);
public Query createNativeQuery (String sql, Class resultCls);
public Query createNativeQuery (String sql, String resultMapping);

Native queries are queries in the datastore's native language. For relational databases, this is the Structured Query Language (SQL). Chapter 11, SQL Queries elaborates on EJB persistence's native query support.


Skip navigation bar   Back to Top