We know that in the ring $mathbb{Z}$, the following equality holds
$$
(I+J)(I cap J) = (IJ)
$$
for any ideals $I$ and $J$ in $mathbb{Z}$. It can interpreted as the fact that for any two integers $a$ and $b$,
$$
mathrm{lcm}(a,b) times gcd (a,b) = ab.
$$
My question is this : Can we generalize this equality to some broader contexts? For example, does this equality holds in an arbitary PID (principal ideal domain) or UFD (unique factorization domain)? Does this equality holds in an arbitary Dedekind domain, etc..
My Ideas and Attempts:

It remains to be true in any PID, as we can directly use the same proof as in proving the fact on the lcm and gcd of two integers.

I do not think that the statement holds in any UFD. But I am not able to provide any counterexample on this and I’m hoping to get one in this question.

Yet does it ture that for any principal ideals in an UFD, the equality remains to be true? (I haven’t proved the above claim.)

Since the ring of integers in algebraic number theory is a generalization of the ring $mathbb{Z}$ in number fields (finite extension of $mathbb{Q}$), does such equality holds in Dedekind domains (or at least the ring of integers $mathcal{O}_K$ for any number field $mathbb{K}$ over $mathbb{Q}$)?
I have calculated for some rings, for example the ring of integers $R = mathbb{Z}(sqrt{5})$. In the ring $R$,
$$(2) = (2, 1+sqrt{5})^2 =: mathfrak{p}_1^2, $$
$$(3) = (3, 1+sqrt{5})(3, 2+sqrt{5}) =: mathfrak{p}_2 mathfrak{p}_2^prime, $$
$$(5) = (5, sqrt{5}) =: mathfrak{p}_3^2.$$
Then consider the ideals
$$ I = (3) mathfrak{p}_1 = mathfrak{p}_2 mathfrak{p}_2^prime mathfrak{p}_1 $$
and
$$ I = (5) mathfrak{p}_1 = mathfrak{p}_3^2 mathfrak{p}_1 . $$
Hence,
$$
I + J = mathfrak{p}_1 mathfrak{p}_2 mathfrak{p}_2^prime mathfrak{p}_3,
$$
$$
I cap J = mathfrak{p}_1 mathfrak{p}_2 mathfrak{p}_2^prime mathfrak{p}_3^2.
$$
Thus,
$$
(I+J)(I cap J) = mathfrak{p}_1^2 (mathfrak{p}_2 mathfrak{p}_2^prime)^2 mathfrak{p}_3^3 = (450, 90 sqrt{5}),
$$
which is not a principal ideal. (I am not sure on this.) Yet
$$
IJ = mathfrak{p}_1^2 mathfrak{p}_2 mathfrak{p}_2^prime mathfrak{p}_3^2 = (30),
$$
which is a principal ideal. Hence such equality does not hold in $R$. This is very strange to me, since the ring of integer is a generalization of $mathbb{Z}$.
Thank you in advance for your answers and sorry for the possible mistakes in this question.