I am trying to understand how I can introduce transactions across services in Spring.
I have organization class and every organization will have a associated superadmin. I am creating an organization and then creating super user for it. But I would like to execute these in a transaction, i.e if super admin creation fails, then organization row which got inserted by createOrganization() method should be rolled back. I am using JOOQ to handle DB operations.
How can I achieve transactions across services(organizationService and userService) ?
addSuperAdmin(Organization organizationObject, SuperUser superUserObject)
{
String orgId = organizationService.createOrganization(organizationObject);
superUserObject.orgId = orgId;
userService.AddSuperAdminDetailsToDB(superUserObject);
}