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 05:13 Go to next message
MITHUN  is currently offline MITHUN
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 09:39 Go to previous message
James Sutherland is currently offline James Sutherland
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: Thu Jul 24 16:07:31 EDT 2014

Powered by FUDForum. Page generated in 0.11234 seconds