This commit fixes various database connection leaks, that possibly occur

Classes:
- BaseModel: Restored MappedSuperclass
- Notification: Add referenceId and referenceType instead of BaseModel reference, as BaseModel should not be an entity as we might have duplicate IDs on seperate tables which might result into problems when indexing
- NotifiationService: Use referenceId and referenceType from Notification
- Post: Put several queries into transactions to avoid connection leaks