I am sending an object from the user interface. This object will be created with reference to an existing child.
This is a simple illustration for this relationship.
class ParentEntity { @Id Long id; @ManyToOne(fetch = FetchType.LAZY) private ChildEntity child; } class ChildEntity { @Id Long id; } ChildEntity child = new ChildEntity(); child.setId(1);
When I save this object, Hibernate gives me "org.hibernate.TransientPropertyValueException: the object refers to an unsaved transient instance."
I do not need to save the child, because I do not change the child at all. Just need to save the child id in the parent table.
I tried to use several CascadeType, but none of them worked.
source share