Home > Back-end >  Why is persistence context called persistence context?
Why is persistence context called persistence context?

Time:09-17

Why is persistence context called persistence context?

Is it context because it acts as a stepping stone until the object is permanently stored in db?

(Because context is a dynamic feeling from where to where rather than a static feeling?)

CodePudding user response:

A context in computing terms is defined as follows:

In computer science, a task context is the minimal set of data used by a task that must be saved to allow a task to be interrupted, and later continued from the same point.
Context_(computing)

A persistence context is a specific context relating to database persistence. Just like any other context it will store required state relating to database persistence.

Is it context because it acts as a stepping stone until the object is permanently stored in db?

JPA works with transactions, sometimes this can appear hidden if using web frameworks that automatically begin and end the transaction for an http request. The persistence context will act as a kind of cache during a transaction storing any database reads. Any updates made are also saved to the context until the transaction is finished or you manually flush, at which point they will be persisted to the database.

  •  Tags:  
  • jpa
  • Related