Monday, 31 May 2010

Querying the database with JPA

When working with entity beans you can retrieve records from the database using Java Persistence Query Language (JPQL), a declarative language similar to SQL but which works with Java objects rather than relational tables. Both dynamic and static queries can be defined with JPQL. Static queries (named queries) are defined in a JPA entity nested within a @NamedQuery annotation. Dynamic queries are defined directly within an application's business logic. The EntityManager interface provides the methods createQuery and createNamedQuery used to create dynamic, respectively static queries.
The Java EE 6 Tutorial presents JPQL in detail. (

No comments: