-->
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.  [ 2 posts ] 
Author Message
 Post subject: Question about list indexes, reordering and performance
PostPosted: Fri Aug 17, 2007 6:00 am 
Newbie

Joined: Fri Aug 17, 2007 4:27 am
Posts: 5
Hi,

I would like to save a big group of object with specific order that could be easily managed (just like a List )
I'm wondering if Hibernate list management (or something else) provides functinality to update ordered indexes ofto objects in a way that

- when I add a new element (in the middle of the list) the indexes wouldn't be changed one at time but with a some kind of "shift update" like "update TABLE set INDEX = INDEX + 1 WHERE INDEX > <index-of-added-element> instead of every index being changed one at time

- same thing with removing an element from the list

First I thought it could done with a list but after some thinking I ended up that it won't probably do it. The PersistentList seems to do some queuing with addition / removal operations but if I understood right, these aren't used with index updating? And so the list solution wouldn't update the indexes with "shift update", or?

Another possibility would be to handle the indexes separately with HQL/SQL UPDATE but then the in-memory state of the list/elements wouldn't be solved. (Ok, I could probably do it by hand..)

So, if anyone has ideas for a good solution that would be nice.

Still working on it,
-Touko


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 23, 2007 10:08 am 
Newbie

Joined: Fri Aug 17, 2007 4:27 am
Posts: 5
Hi again,

replying mostly to help if someone has similar needs and to ask if somebody has good point on doing things this way:

After some thinking and a little bit of prototyping one way to do the wanted thing could be something like that:

- Forget the automatic indexing & ordering with List and make the index column a normal property.

- Handle the indexes manually and do the shift operations with HQL resulting as something like
Code:
update Foo set Foo.index = Foo.index + :shift where index >= :min and index <= :max


Even though legacy databases without much object orientation and with some mass operations don't seem to be the main target of Hibernate but it still seems that Hibernate would save a lots of work with the thing..


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

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.