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.  [ 3 posts ] 
Author Message
 Post subject: Collection Sorting
PostPosted: Tue May 31, 2005 12:27 pm 
Newbie

Joined: Thu Mar 03, 2005 1:52 pm
Posts: 5
I need to sort a collection with respect to a sorting criteria specified by the user.

Problem is everytime I sort the collection using Collections.sort(hibernateCollection)

Hibernate always recreates the associations when saved creating a new IDs everytime.


Top
 Profile  
 
 Post subject: Collection sorting
PostPosted: Tue May 31, 2005 1:42 pm 
Beginner
Beginner

Joined: Thu Nov 11, 2004 12:18 pm
Posts: 37
Location: Baltimore, MD
Sorting the collection shouldn't be a problem as long as the collection reference doesn't change. Can you post your mapping of this collection and possibly the code you are calling to save it?

_________________
-Chris


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 02, 2005 1:54 pm 
Newbie

Joined: Thu Mar 03, 2005 1:52 pm
Posts: 5
I'm using a BAG for mapping and digging into the hibernate documentation, I found this from http://www.hibernate.org/hib_docs/refer ... ollections
Section 14.1.1

"Bags are the worst case. Since a bag permits duplicate element values and has no index column, no primary key may be defined. Hibernate has no way of distinguishing between duplicate rows. Hibernate resolves this problem by completely removing (in a single DELETE) and recreating the collection whenever it changes. This might be very inefficient."

This could be the reason why i'm seeing a single DELETE statement and a lot of INSERT statement in the Hibernate logs.


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