e.g. OrganizationLocalServiceBaseImpl implements two methods for deleting organizations:
- deleteOrganization(long organizationId)
- deleteOrganization(Organization organization)
By default, these methods forward to the persistence's delete methods, that will only remove a row in the Organization database table.
However, the deleteOrganization(long organizationId) is overwritten in OrganizationLocalServiceImpl, a subclass of OrganizationLocalServiceBaseImpl. In this overwritten method, links with other tables (group, resource, phone number, etc.) are removed as well, which is desired behaviour to leave the database tables consistent.
Because OrganizationLocalServiceImpl doesn't overwrite deleteOrganization(Organization org), if you call that method in OrganizationLocalServiceUtil, only the organization record will be removed and not all its references, causing stale data to be left behind. At least, deleteOrganization(Organization org) should be overwritten as well in OrganizationLocalServiceImpl, OR (even better) there should be only one method for entity deletion, that is overwritten in the service as required.
This behaviour does not only exist for organizations, but for almost all Liferay entities. It is very easy for developers to, by mistake, call the "wrong" delete service method and cause data inconsistency. This error is very hard to trace as well. We discovered the issue on a client that is almost a year in production now.