-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate not updating index column on reordering
PostPosted: Fri Feb 19, 2010 7:30 am 
Newbie

Joined: Tue Dec 07, 2004 12:44 pm
Posts: 13
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.