Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] two instances of same object in an indirectList ?

HI Tom, thanks for the response.  I can certainly attempt to post the definition.

On one side of the relationship the entity has two properties as follows:

@ManyToOne(cascade={CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH})
 private Department department;

@ManyToOne(cascade={CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH})
private OpeningStatus status;

While on the other side, the properties are as follows:

@OneToMany(mappedBy = "department", cascade={CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH})
private Collection<Opening> openings;

and

@OneToMany(mappedBy = "status", cascade={CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH})
private Collection<Opening> openings;


I've worked around the issue for now by redefining all of the Collection based properties as Set based instead.  Luckily they all fit within the Set semantics so I'm happy to leave them that way.  But I'm still wondering why the underlying Lists contain duplicates, or... are lists at all rather than sets.  I should mention again that the query involves invoking find() on an entity manager with either a Department or OpeningStatus and both of those have Collection based relational properties mapped to OpeningStatus and Department.  But the underlying Collection is an IndirectList (when running inside the container) and a HashSet when running outside.

Thanks
- Phillip



----- Original Message ----
> From: Tom Ware <tom.ware@xxxxxxxxxx>
> To: EclipseLink User Discussions <eclipselink-users@xxxxxxxxxxx>
> Sent: Tuesday, January 6, 2009 9:30:03 AM
> Subject: Re: [eclipselink-users] two instances of same object in an indirectList ?
> 
> Hi Phillip,
> 
>   I am a bit surprised that you are getting a TransparentList.  I would expect a 
> TransparentSet.  Can you post the definition of the relationship?
> 
> -Tom
> 
> Phillip Ross wrote:
> > Hi all... I'm looking for some quick ideas.
> > 
> > Was wondering if someone could quickly think of a few things for me to check 
> out with a problem I'm having.  I have a pair of entities with OneToMany 
> relationships to a third entity.  If I return an instance with the entity 
> manager using find and PK id, I get an instance and the Collection contains two 
> items.  Both items are references to the same related object... exact hashCodes, 
> etc.  When I run outside the container, the Collection is a HashSet and it only 
> contains one reference to the related item due to the Set semantics which works 
> great... but inside the container the Collection is an eclipselink specific 
> IndirectList but with dups of the same item.
> > 
> > So, might there be something I'm doing wrong that's creating the dups in the 
> indirect list?  I have several other similar OneToMany relations to other 
> entities and they don't exhibit the problem, but I've been racking my mind 
> trying to figure out if there is something I'm missing here to get the dedup to 
> happen on the IndirectList.  There are several things I'm sure I could implement 
> myself to work around all of this and handle deduping and such, but I'm really 
> wondering why this duplication happens in the indirect list with these specific 
> entities and not with the other three or four other similarly patterned 
> OneToMany related entites.
> > 
> > Any ideas?  I'm using eclipselink 1.0.2, container is glassfish v2.1-b60e 
> (tried with earlier glassfish versions as well).
> > 
> > Thanks!
> > - Phillip
> > 
> > _______________________________________________
> > eclipselink-users mailing list
> > eclipselink-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users



Back to the top