79338655

Date: 2025-01-08 10:01:38
Score: 1.5
Natty:
Report link

Disagree with all the previous answers:

I would recommend manually performing all necessary validation checks before executing the persistence or database operation. For example, verify whether related entities exist or any foreign key dependencies are present. If a violation is detected, you can throw an IllegalStateException or a custom exception that clearly indicates the issue. This approach ensures that your business logic is handled explicitly in your service layer rather than relying on database constraints to handle errors.

Refference: https://stackoverflow.com/a/77125211/16993210

Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: fromSeri