-->
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: Ordering and duplication in Bags and Sets
PostPosted: Thu Nov 17, 2005 6:45 am 
Newbie

Joined: Thu Nov 17, 2005 5:50 am
Posts: 6
How could you handle the following situation using Hibernate, if at all?

( I dont actually need to do this - Im just thinking about it to check my understanding - comments would be appreciated)

An association that maintains order but does not load the entire collection on insert of new records

AFAIK if you want to have an association collection that is ordered and maintains that order when you insert new records then you have to use a
Set (or Map) and specify sort as 'natural' or provide a comparator in the hbm.

A side effect of this (for sets at least) seems to be that if the association is lazy, then inserting a new record will trigger all the persisted records to be loaded ( since the set needs to check if the new record is a duplicate ).

Ideally, though, If I dont care about duplicates, I'd like to have a ordered lazy collection that only loads all the persisted records when and if I start iterating across it, not when I insert, but the need to use a set prevents this.

I guess the ideal solution would be support for new 1.5 things like queues- specifically PriorityQueue - but in the meantime can anyone think of a way to do this?

perryn


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.