persistence context
The set of entities JPA is currently tracking in a unit of work, whose changes it writes to the database automatically.
In more detail
Loading an entity inside a transaction makes it managed; changing a field is then enough to update the row at commit. Lazy relationships only load while the context is open. Controllers should never see or manage database sessions.
Related terms
- JPA entity — A class marked @Entity whose instances JPA stores as rows in a table, identified by a field marked @Id.
- transaction — A group of database changes that succeed or fail together, so the data is never left half-updated.
- lazy loading — Loading related data from the database only when code first accesses it, instead of together with the object that refers to it.
Taught in
- Persistence With JPA And Hibernate — Modern Java: Virtual Threads & High-Throughput Services
- Spring Data Repositories — Modern Java: Virtual Threads & High-Throughput Services