Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure REST Data Panache updates happens in a single transaction #15640

Merged
merged 1 commit into from
Mar 15, 2021

Conversation

gytis
Copy link

@gytis gytis commented Mar 11, 2021

A couple of weeks ago I've removed the @transactional annotations from the generated JAX-RS resource methods and added them on the RestDataPanache resources that perform data access and modification operations. However, this caused an update endpoint to execute two transactions: one for checking if an entity exists and another to update it. I removed the annotation from the JAX-RS in order to be able to wrap all exceptions (including transaction exceptions) in a custom exception to allow custom error mapping. Therefore, I didn't want to bring it back.
In order to work around this issue I've added a TransactionalExecutor bean which takes an instance that implements a functional interface and executes it inside a transaction. I thought that this approach is clearer that a bean managed transaction.

fixes #15369

@quarkus-bot
Copy link

quarkus-bot bot commented Mar 11, 2021

Thanks for your pull request!

The title of your pull request does not follow our editorial rules. Could you have a look?

  • title should preferably start with an uppercase character (if it makes sense!)
  • title should not start with chore/feat/fix/docs but be a proper sentence

This message is automatically generated by a bot.

@gytis gytis force-pushed the rest-data-panache-update-transaction branch from 880f481 to 0e874e2 Compare March 11, 2021 15:33
@gytis gytis changed the title fix: REST Data Panache update in a single transaction REST Data Panache update in a single transaction Mar 11, 2021
@geoand
Copy link
Contributor

geoand commented Mar 12, 2021

Hm...

It seems like now there are a bunch of conflicts because I merged your other PR

@geoand geoand changed the title REST Data Panache update in a single transaction Ensure REST Data Panache updates happens in a single transaction Mar 12, 2021
@gytis
Copy link
Author

gytis commented Mar 12, 2021

Yes that was expected. I had an identical test in another PR that was merged this morning. I'll rebase it.

Base automatically changed from master to main March 12, 2021 15:55
@gytis gytis force-pushed the rest-data-panache-update-transaction branch from 0e874e2 to 269084c Compare March 12, 2021 16:05
@gytis gytis force-pushed the rest-data-panache-update-transaction branch from 269084c to 7998719 Compare March 15, 2021 10:55
@gytis gytis requested a review from geoand March 15, 2021 10:57
@geoand geoand added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Mar 15, 2021
@geoand geoand merged commit b65d71d into quarkusio:main Mar 15, 2021
@quarkus-bot quarkus-bot bot added this to the 1.13 - master milestone Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/panache triage/waiting-for-ci Ready to merge when CI successfully finishes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panache Data REST: Update method requires at least two connections
2 participants