O'Reilly logo

EJB 3.1 Cookbook by Richard M. Reese

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required