Chapter 5. Callbacks and Listeners

In the previous chapter, you saw how to query mapped entities. Now you know how to persist, remove, update, and find an entity by its identifier. With JPQL, you can retrieve one or more entities according to certain search criteria with dynamic, static, and native queries. All these actions are carried out by the entity manager—the central piece that manipulates entities and manages their life cycle.

I described the entity life cycle by saying that entities are managed by the entity manager (meaning that they have a persistence identity and are synchronized with the database) or are detached from the database and used as normal POJOs. But the life cycle of an entity is slightly richer. Importantly, JPA allows ...

Get Beginning Java™ EE 6 Platform with GlassFish™ 3 now with O’Reilly online learning.

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