-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fix transactional annotation #419
base: main
Are you sure you want to change the base?
Conversation
1ab4762
to
d6e2c24
Compare
@@ -344,7 +350,6 @@ class PrisonerIepLevelReviewService( | |||
) | |||
} | |||
|
|||
@Transactional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the only existing call to this method is from the processOffenderEvent
in this class so the transactional annotation has no effect. but sadly we cannot make it private as there's a test case using it.
@@ -135,6 +135,7 @@ class PrisonerIepLevelReviewService( | |||
suspend fun getReviewById(id: Long): IepDetail = | |||
prisonerIepLevelRepository.findById(id)?.toIepDetail(incentiveLevelService.getAllIncentiveLevelsMapByCode()) ?: throw NoDataFoundException(id) | |||
|
|||
@Transactional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding annotation here so all effects of the received event are transactional now… is that too much? is there any harm in createIepForReceivedPrisoner
becoming transactional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BUT if createIepForReceivedPrisoner
or mergedPrisonerDetails
were to raise domain events, then they might be received by another party prior to the transaction committing leading to a read of stale data!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
f12ad5e
to
02806b6
Compare
02806b6
to
29c1977
Compare
Spring only creates transactions when calling annotated methods on _other_ classes, invocations on `this` will not create transactions as the proxy object isn't used
29c1977
to
75a0871
Compare
Spring only creates transactions when calling annotated methods on other classes using a proxy object, invocations on
this
will not create transactions as the transaction-managing proxy object isn’t used.🚨 Since transactions haven’t been created in practice, I’m not sure how safe this change is! If our event-receiving leads to DB changes and new events being published, they might be received by third parties prior to data being fully persisted.