I was wondering if anyone has a good solution to a problem I\'ve encountered numerous times during the last years.
I have a shopping cart and my customer explicitly
When I use Hibernate, and need to save the order of a @OneToMany, I use a Map and not a List.
@OneToMany(fetch = FetchType.EAGER, mappedBy = "rule", cascade = CascadeType.ALL)
@MapKey(name = "position")
@OrderBy("position")
private Map actions = LazyMap.decorate(new LinkedHashMap<>(), FactoryUtils.instantiateFactory(RuleAction.class, new Class[] { Rule.class }, new Object[] { this }));
In this Java example, position is an Integer property of RuleAction so the order is persisted that way. I guess in C# this would look rather similar.