Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 10:13 Go to next message
MITHUN  is currently offline MITHUN Friend
Messages: 2
Registered: November 2010
Junior Member

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 14:39 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

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.


James : Wiki : Book : Blog : Twitter
Previous Topic:Problems executing a Stored Procedure
Next Topic:IntegrityConstraintViolationException when merging new entity in derby
Goto Forum:
  


Current Time: Fri Apr 26 02:42:51 GMT 2024

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

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

Back to the top