Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » Entity.getChildList().add(childEntity) :child entity is not persisted.(Bi directional relation in entity b/n parent and child, child is not getting persisted.)
Entity.getChildList().add(childEntity) :child entity is not persisted. [message #640487] Mon, 22 November 2010 05:13 Go to next message
Eclipse UserFriend

Hello

i am having a parent enity with the following relation with a child entity.
@OneToMany(mappedBy="studyTreatmentGrp", cascade={CascadeType.ALL}, fetch=FetchType.LAZY)


in the child entity the relationship is as follows
@ManyToOne(cascade={CascadeType.PERSIST,CascadeType.MERGE,Ca scadeType.REFRESH}) @JoinColumn(name="S_TREAT_GROUP_ID")

i am adding child entity to the existing collection using entity.getChildList().add(childEntity),
but some times the child entity is not getting persisted.
Re: Entity.getChildList().add(childEntity) :child entity is not persisted. [message #640583 is a reply to message #640487] Mon, 22 November 2010 09:39 Go to previous message
Eclipse UserFriend
Ensure you are setting both sides of the bi-directional relationship. If you add the child to the collection, also set its parent. Normally you would define an addChild() method on the parent that sets the back reference instead of adding directly to the collection.
Previous Topic:Problems executing a Stored Procedure
Next Topic:IntegrityConstraintViolationException when merging new entity in derby
Goto Forum:
  


Current Time: Sat Jul 05 17:27:16 EDT 2025

Powered by FUDForum. Page generated in 0.22184 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top