'How to avoid updating child table when data is null or blank?
I have entity parent in which I am using @SecondoryTable. Secondary table have one info as attribute. Now when I save parent, child is saving automatically.
But I don't want to save child if child data is null. I want to save parent but not child in that case. Which annotation should I use to fixed this in entity?
Solution 1:[1]
That's not possible.
If you want to have the relation optional you must use a @OneToOne relationship instead.
Solution 2:[2]
We can achieve this by using below approach.
In your parent entity where you have defined @SecondoryTable there you have suppose child column so during parent save you need to set the null value in parent for that child attribute.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Simon Martinelli |
| Solution 2 |
