Skip to content

OBGM-468 Fix no transaction for product type update and delete methods#4156

Merged
awalkowiak merged 4 commits intofeature/upgrade-to-grails-3.3.10from
OBGM-468-fix
Jul 13, 2023
Merged

OBGM-468 Fix no transaction for product type update and delete methods#4156
awalkowiak merged 4 commits intofeature/upgrade-to-grails-3.3.10from
OBGM-468-fix

Conversation

@kchelstowski
Copy link
Collaborator

Katarzyna has asked me to fix also update and delete methods in this ticket, so those are the changes to include them.

Copy link
Collaborator

@drodzewicz drodzewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the changes you have made reminded me of what Justin mentioned not too long ago about not wanting to create separate domain-based services.
Although it is not the exact case here, I think we can avoid implementing simple get() delete() etc... actions in services and instead use a generic approach like GenericApiService.
Both delete and get are already implemented there

@drodzewicz
Copy link
Collaborator

Alternatively, there is also this approach of creating an abstract class with generic actions and extending some other services with this abstract class like it is shown in the examples of this little article.
Both approaches are in my opinion good and it is just a matter of preference, but either way, it definitely reduces the amount of redundant code that we have to implement and keeps the codebase a little bit more DRY.

@kchelstowski
Copy link
Collaborator Author

@drodzewicz as for get I can agree, but I don't like the delete method of genericApiService. It does an unnecessary additional fetch to get the object and then to delete it, so I'd have N+1 queries there.

@kchelstowski kchelstowski requested a review from drodzewicz July 11, 2023 12:19
@awalkowiak awalkowiak merged commit 591528b into feature/upgrade-to-grails-3.3.10 Jul 13, 2023
@awalkowiak awalkowiak deleted the OBGM-468-fix branch July 13, 2023 15:18
Copy link
Member

@jmiranda jmiranda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

By the way, this is one of those scaffolded CRUD controllers that I'd prefer to be @transactional until we figure out where these methods should go i.e. probably ProductService. But since this one snuck in, we can grandfather it in and refactor later if we choose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants