Ensure database consistency
currently, entity ids are not checked with saved elements, which could lead to non-referencable elements in the database. Other potential problems might exist, find them and solve them at base dao level.
(from redmine: issue id 430, created on 2018-01-22tgradl)