[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] JPA 2 @OrderColumn question
|
Hi James,
On Jun 7, 2012, at 10:44 AM, James Sutherland wrote:
>
> Set, and HashSet are not ordered. These collection types have no order in
> Java, so I'm not sure what expect???
I was hoping to get the best of both worlds, use a collection which enforces uniqueness (so I don't have to deal with constraint violation exceptions - see my comment below) and w/@OrderColumn get ordering enforced in the join table.
>
> If you want order, you need to use a List in Java. Lists are generally more
> usable collection types.
> You can add a constraint to your join table to enforce no duplicates.
Adding a constraint adds with a List just means I'm going to end up with constraint violation exceptions since its not going to be enforced on the Java side - unless I add an O(n) check on insertion. Not something I really want to deal with.
It seems to be like it should be possible for EclipseLink to support @OrderColumn on a Set such that when it fetches the items for the relationship collection it inserts them into a LinkedHashSet in the order dictated by the @OrderColumn column and thus you would get an ordered Set.
-Noah