Using the Select query

The Select query is a very useful query as it returns a subset of one or more tables of a database. The query can be used to select which rows of a table should be returned and which fields of each row. When the query is executed a list of results is returned and can be processed and/or displayed by the application.

Getting ready

The steps used to create and use a JPQL Select query include:

  1. Obtaining an instance of an EntityManager
  2. Using the createQuery method to create an instance of a Query based on a Select JPQL string argument
  3. Using a method such as the getResultList to execute and return the results of the query

    The easiest place to find an instance of the EntityManager is in a facade class. This is where we will place our ...

Get EJB 3.1 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.