You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spec/src/main/asciidoc/repository.asciidoc
+4-10Lines changed: 4 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -999,19 +999,17 @@ Support for stateful repositories is defined in the dedicated module `jakarta.da
999
999
1000
1000
==== Persistence contexts
1001
1001
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.
1003
1003
1004
1004
- An entity instance never belongs to multiple persistence contexts.
1005
1005
1006
1006
- The Jakarta Data implementation must ensure that a given persistence context never contains more than one entity instance representing the same record.
1007
1007
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.
1011
1009
1012
1010
- A persistence context is never shared across transactions.
1013
1011
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.
1015
1013
1016
1014
[WARNING]
1017
1015
====
@@ -1020,10 +1018,6 @@ If an application program accesses an entity instance belonging to a persistence
1020
1018
1021
1019
This specification does not define the lifecycle of a persistence context, nor how a persistence context is propagated across repositories.
1022
1020
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
-
1027
1021
[NOTE]
1028
1022
====
1029
1023
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
1049
1043
Such changes to the database do not typically happen synchronously with invocation of the lifecycle method, or immediately after modification of the managed entity.
1050
1044
Instead, such changes are made when the persistence context is periodically _flushed_.
1051
1045
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.
1053
1047
An implementation of Jakarta Data should flush as needed to ensure that query results are consistent with the current state of the persistence context.
0 commit comments