-->
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.  [ 4 posts ] 
Author Message
 Post subject: Updating list-like indices
PostPosted: Wed Nov 26, 2003 2:30 am 
Beginner
Beginner

Joined: Mon Sep 15, 2003 6:55 pm
Posts: 29
I have a collection which is a bag, however each item in the collection has a displayIndex much like an index in a list. Is is possible to write a statement in hql like "add 1 to every displayIndex that is greater than 17"? I know I can retrieve them and update them myself, but I'm worried about what will happen when the collection gets a lot of stuff in it.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2003 2:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I think this is a good case for direct SQL/JDBC


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2003 2:33 am 
Beginner
Beginner

Joined: Mon Sep 15, 2003 6:55 pm
Posts: 29
I've learned hql, but I'm pretty fuzzy with sql. Do you know if it's possible with sql? (I've already tried searching, but can't find much)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2003 2:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Code:
PreparedStatement ps = session.connection().prepareStatement("update foo set display_index = display_index +1 where display_index > 17 and id = ?");
etc...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.