Hi. I'm using Hibernate-JPA and I'm facing problems with the reordering of an indexed collection.
This is the mapping:
Code:
@OneToMany(cascade={CascadeType.ALL})
@JoinColumn(name="parent_id")
@IndexColumn(name="position")
public List<Component> getComponents() {
return components;
}
If I pass to EntityManager.merge() an object which some of the elements in that list reordered, Hibernate won't persist the changes, and the index column will stay as it is. But if I reorder them and add a new object, then the new one is persisted AND the index column is updated correctly for the reordered elements. So it's as if Hibernate wouldn't notice the change in the position.
But, and this is even more strange, if inside my transactional method I change manually the position of some objects using java.util.Collections.swap(), then the changes are persisted, but if I pass the collection already reordered to the transactional method, then it won't persist the changes by invoking merge().
What can be the cause of this behavior?
I'm using Hibernate Core 3.3.2.GA, Hibernate Annotations 3.4.0.GA and Hibernate Entity Manager 3.4.0.GA.
Thanks in advance.