I am trying to save a CDT to a datastore which has another CDT as a child object

Certified Associate Developer
I am trying to save a CDT to a datastore which has another CDT as a child object but I am receiving a 'cannot save a null or transient value' error from hibernate.

I would like to save both objects in a single transaction and I have mapped the relationship with 'Cascade=PERSIST' to achieve this but still haven't been able to achieve this. I have also tried setting Cascade to 'ALL' with the same results. Does anyone have any ideas about what else may be wrong?...

OriginalPostID-40694

OriginalPostID-40694

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Associate Developer
    Nullable=true was already set however setting the child object with 'Optional=TRUE' did give me a different error: (paraphrasing) Cannot set null childID in parent.childID.

    It appears hibernate is trying to save the parent before the child object is flushed so there's no childID to save the relationship with. I cannot remove the 'NOT NULL' restraint on the column for integrity reasons so that's also not an option.
Reply
  • 0
    Certified Associate Developer
    Nullable=true was already set however setting the child object with 'Optional=TRUE' did give me a different error: (paraphrasing) Cannot set null childID in parent.childID.

    It appears hibernate is trying to save the parent before the child object is flushed so there's no childID to save the relationship with. I cannot remove the 'NOT NULL' restraint on the column for integrity reasons so that's also not an option.
Children