There are objects, like ADT templates, that can be deleted even when they are being used by a portlet,, so data inconsistence is created.
Steps to reproduce for ADT templates: See
So for every object that a reference is stored at portletpreferences, a validation must be done before execute the deletion operation to avoid inconsistencies.
For example, for ADT templates we can check it at deletion time, executing following SQL
This SQL perhaps is a bit is expensive because of "like" commands, perhaps a new column or table with references must be stored to allow a quicker check at deletion time.