Skip to content

StatefulRepository with flush method?#1424

Closed
njr-11 wants to merge 1 commit into
jakartaee:mainfrom
njr-11:statefulrepository-interface-with-flush-method
Closed

StatefulRepository with flush method?#1424
njr-11 wants to merge 1 commit into
jakartaee:mainfrom
njr-11:statefulrepository-interface-with-flush-method

Conversation

@njr-11
Copy link
Copy Markdown
Member

@njr-11 njr-11 commented Apr 14, 2026

For discussion at the Jakarta Data meeting:
Do we need something like this for applications that use a stateful repository to modify a persistence context outside of a transaction?

Person person = people.find(ssn);
person.setHomeAddress(newAddress);
person.setZipCode(newZipCode);

Without a flush operation, how can the application know that its changes will be persisted vs lost?
The same applies to our TCK tests. In order to make assertions about what went in to the database, we need guarantees that operations we perform will be persisted after a certain point.

@njr-11 njr-11 added this to the 1.1 milestone Apr 14, 2026
@njr-11 njr-11 added the design Improvements or additions to design label Apr 14, 2026
@gavinking
Copy link
Copy Markdown
Member

For discussion at the Jakarta Data meeting:

Which meeting? Isn't the meeting later today?

Do we need something like this for applications that use a stateful repository to modify a persistence context outside of a transaction? Without a flush operation, how can the application know that its changes will be persisted vs lost?

I don't know what you're trying to say here, but I'm pretty sure the answer is "no".

@gavinking
Copy link
Copy Markdown
Member

Isn't the meeting later today?

Oh, you wrote "for", not "from". Sorry, misread.

@njr-11
Copy link
Copy Markdown
Member Author

njr-11 commented Apr 15, 2026

Canceling this PR after agreement on today's Jakarta Data call that stateless repositories are not intended to make updates or have lifecycle methods run outside of a transaction. PR #1429 adds documentation of that restriction.

@njr-11 njr-11 closed this Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

design Improvements or additions to design

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants