For what it's worth, I have always avoided this issue by only using
the artist.setPainting(painting) method and never the
painting.addToArtist(artist) method.
Another possibility would be to have the generated template addTo*
method do the check as Andrus points out:
if(!user.getRoles().contains(role)) {
user.addToRoles(role);
}
On Wed, Mar 5, 2008 at 11:52 AM, Andrus Adamchik <andru..bjectstyle.org> wrote:
>
> On Mar 5, 2008, at 6:32 PM, Kevin Menard wrote:
>
> > I don't think anyone wants to have duplicates. That's probably the
> > largest
> > issue at hand. Telling everyone to do duplicate checks on
>
> > all tomany relationships for all entities is a bit of a bummer.
>
> Why is that a problem? The cases where duplicates could occur should
> be expected by the user. Those are well-defined cases in the
> application, not some obscure side effects of using Cayenne. E.g. I
> always do that, and don't think this is a big deal:
>
> if(!user.getRoles().contains(role)) {
> user.addToRoles(role);
> }
>
> That's no different from List.add(..) logically.
>
>
> > I have yet to map a relationship as a Set. Does the set
> > implementation used preserve iteration order?
>
> No, it is a HashSet.
>
>
> > If so, I'd advocate this being the default rather than List. Then, if
> > someone is worried about performance or random access, he can
> > explicitly
> > choose the List.
>
> -1. The performance impact will be huge.
>
>
> > Otherwise, data integrity is the default.
>
> Data integrity is not compromised. Everything that is saved to the DB
> is correct.
>
> Andrus
>
This archive was generated by hypermail 2.0.0 : Wed Mar 05 2008 - 12:11:47 EST