Skip to content

Commit b829df3

Browse files
committed
Redo changes per Gavin's review comment focus on the association being contextual
1 parent 4260442 commit b829df3

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

spec/src/main/asciidoc/repository.asciidoc

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -999,19 +999,17 @@ Support for stateful repositories is defined in the dedicated module `jakarta.da
999999

10001000
==== Persistence contexts
10011001

1002-
Each operation on a stateful repository is associated with a _persistence context_, a set of managed entity instances in which at most one instance represents a given record in the database.
1002+
A stateful repository operation applies to a _persistence context_, a set of managed entity instances in which at most one instance represents a given record in the database. Persistence context can span multiple repository operations, such as all operations performed within a transaction.
10031003

10041004
- An entity instance never belongs to multiple persistence contexts.
10051005

10061006
- The Jakarta Data implementation must ensure that a given persistence context never contains more than one entity instance representing the same record.
10071007

1008-
- Multiple operations on a single repository, in particular those running in the same transaction or thread, can share a persistence context.
1009-
1010-
- Operations on multiple repositories might share a persistence context, especially if the repositories share a datastore.
1008+
- Multiple repositories might share a persistence context, especially if they share a datastore.
10111009

10121010
- A persistence context is never shared across transactions.
10131011

1014-
A query method of a stateful repository which returns an entity type always returns managed instances belonging to a persistence context associated with the repository.
1012+
A query method of a stateful repository which returns an entity type always returns managed instances associated with the persistence context under which the repository operation is running.
10151013

10161014
[WARNING]
10171015
====
@@ -1020,10 +1018,6 @@ If an application program accesses an entity instance belonging to a persistence
10201018

10211019
This specification does not define the lifecycle of a persistence context, nor how a persistence context is propagated across repositories.
10221020

1023-
===== Persistence context within a transaction
1024-
1025-
All operations performed on a given repository that participate in a given transaction must run under the same persistence context. The Jakarta Data provider must ensure that the persistence context is flushed prior to or during the before completion phase of transaction commit.
1026-
10271021
[NOTE]
10281022
====
10291023
Implementations of Jakarta Data are encouraged to propagate a single persistence context within a given transaction across repositories which share a given data store.
@@ -1049,7 +1043,7 @@ Invocation of a lifecycle method or modification of the state of a managed entit
10491043
Such changes to the database do not typically happen synchronously with invocation of the lifecycle method, or immediately after modification of the managed entity.
10501044
Instead, such changes are made when the persistence context is periodically _flushed_.
10511045

1052-
NOTE: This specification does not prescribe the timing of flush operations for persistence context that does not participate in a transaction.
1046+
NOTE: This specification does not prescribe the timing of flush operations, but a flush typically happens before execution of a query or during the before completion phase of transaction commit.
10531047
An implementation of Jakarta Data should flush as needed to ensure that query results are consistent with the current state of the persistence context.
10541048

10551049

0 commit comments

Comments
 (0)