79667494

Date: 2025-06-16 11:15:17
Score: 0.5
Natty:
Report link

The Listing has Cascadetype.REMOVE. This means only that if you delete your listing, all associated pictures get deleted too. For your use case you need CascadeType.PERSIST or .ALL.

    @OneToMany(mappedBy = "listing", cascade = CascadeType.ALL)
    private List<PictureEntity> pictures;

If you still have problems you should also check your DB if your foreign keys and references are defined correctly and with correct names.

Here is a simple but good introduction into the cascade types and how they interact with hibernate lifecycle:

https://medium.com/@himani.prasad016/jpa-hibernate-cascade-types-0490be19cc1f

Reasons:
  • Blacklisted phrase (0.5): medium.com
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Retros_x