DatabaseImagePersistenceStrategy: throw ImagePersistenceException instead of RuntimeException.

This also fixes 2 PMD warnings.

No functional changes.