Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » one to many bidirectional self reference - problem(not getting children from parent in the case of one to many bidirectional self reference)
one to many bidirectional self reference - problem [message #988974] Tue, 04 December 2012 06:51 Go to next message
vamsi raghava is currently offline vamsi raghavaFriend
Messages: 2
Registered: December 2012
Junior Member
Hi All,

I have self reference one to many bidirectional relationship.
while persisting a child i am doing the following.

1. getParentById(parentId);
2. parent.getChildern().add(child);

The children is getting persisted. I could even see the relationship column getting populated (parentID is getting populated in childs "parentID" column ).

problem is when i retrieve the parent with id and try to get the children of that parent i am not getting, even though the DB shows relation ship.

1. getParentById(parentId);
2. parent.getChildren(); // getting emptyList here.

Even checked the logs, could see the SELECT query for the parent but no query is fired when i say parent.getChildren(). "lazyLoading" is enabled.

The same scenario works fine with Junits in standalone environment.

In weblogic10.3.5 with eclipselink version 2.4.0 ... we are facing this problem.

Thank You.
Re: one to many bidirectional self reference - problem [message #989104 is a reply to message #988974] Tue, 04 December 2012 15:43 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

You need to set both sides of any relationship. Otherwise your objects are corrupt (in the cache).

Refreshing the object will reset it to the database state, but you need to fix your code to maintain both sides of the relationship.


James : Wiki : Book : Blog : Twitter
Previous Topic:Temporal Type in Dynamic JPA
Next Topic: Issue with inheritance and join fetching
Goto Forum:
  


Current Time: Fri Apr 26 00:51:46 GMT 2024

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

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

Back to the top