Well this is a huge Pandora box; one of the unsolved fundamental problems of ORM in Java.
Theoretically, Hibernate ORM as the capability to enhance entities for automatic handling of both sides of a relation.
In practice, I've disabled this in Quarkus and wouldn't recommend using it as we figured there's a huge amount of complex implications and unexpected side effects, so I think it's a really bad idea. Having the users explicitly code what they want to happen is the safest bet.
I do agree that people often don't notice and it's a bit confusing. It would be nice if we could detect the inconsistency, but I'm not sure if we can do it safely; it would be tricky to avoid both false positives and false negatives for the same reason we couldn't have it do "the right thing" automatically.
FWIW, this problem only exists among users who insist in detaching complex graphs sourced from external end points and wanting to re-attach a full graph in one go (or persist, like in this example); I know it's popular but I keep saying that it's a bad idea :) Use a different DTO and code the mapping explicitly, it might look tedious but you're in control and can avoid weird magical side effects; It's also hard to automate as the notion of what is the right thing to do is highly contextual, this really needs explicit user direction.
Last time I was able to dedicate some solid time to this issue my conclusion was that we'd need object relations to be represented by custom collection types (new APIs) which would be more suited to express the relational models. But that's a sad conclusion as it implies you're no longer a pure ORM, as you'd be enforcing the Java object representation rather than allowing people to map standard, untainted POJOs.
This could certainly use some improvements, but be warned it's very tricky.