-->
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.  [ 6 posts ] 
Author Message
 Post subject: List mapping : index column management questions
PostPosted: Wed Jul 20, 2005 9:20 pm 
Regular
Regular

Joined: Fri Oct 01, 2004 2:19 am
Posts: 111
Location: Melbourne, Australia
Hibernate version: 3.0.5

I have read the documentation regarding indexed collections, but I have
not found (in the reference manual at least) an answer to several
questions about managing list collections with Hibernate:

0. Does the list index column need to also be a property of the child
object, or does it only need to be declared as a column in the db?

1. Does Hibernate compute the list index for a list element? I am not
clear on what happens when, for example the object containing a
list is loaded, and presumably the list itself is only lazily loaded, and
then an item is added to the list or inserted in the middle - who's
responsible for making sure the list stays consistent?

2. When/where does this happen if Hibernate does compute the list
index? Does this happen when flushing new objects?


3. One solution I've seen for managing the list index is presented in
http://www.hibernate.org/193.html However, there are several
questions I have regarding this:
    a. A performance/efficiency issue: what happens when the list gets large
    (100's or 1000's of items) and the 'getIndex()' is being called?
    In particular is the list is initialised lazily and list items are
    retrieved as they are being accessed. Is this a price that needs to
    be paid or is this not an issue?

    b. What if the index column is something that consitutes part of the
    natural key (something like order line number) - when retrieving
    the element index value, the solution uses the 'indexOf' method on
    the parent object's list, which uses the 'equals' method, causing
    infinite recursion. How does one avoid this?

Thanks in advance for any assistance here.[/list]

_________________
Cheers,

Bonny

please don't forget to rate :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 9:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
0.

Not unless inverse="true". It is possible to have a unidirectional one-to-many list in HB3. This is better explained in the (unpublished) HB3.1 docs.

1.

I don't quite follow. If foo = list.get(3) then 3 is the index of foo.

2.

Whenever the collection is flushed. Yes, you can rearrange elements and HB will update things correctly.

3.

This is obsolete stuff that referred to HB2.


Caveat: We DO NOT recommend lists as a good thing to use in data modelling. Professional data modellers do not use such inelegant constructs.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 9:39 pm 
Beginner
Beginner

Joined: Wed Jul 21, 2004 6:50 pm
Posts: 27
Hi Gavin,

Quote:
Caveat: We DO NOT recommend lists as a good thing to use in data modelling. Professional data modellers do not use such inelegant constructs.


What do you recommend instead of a list for an ordered collection attached to an object? eg I have an object with a set of filters associated with it, and those filters need to be kept in order.

cheers,

David


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 9:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You should order things by truly *meaningful* information.

eg. use a set with order-by="createdDateTime"


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 21, 2005 3:43 am 
Newbie

Joined: Fri Jul 15, 2005 6:35 am
Posts: 12
Have you solved your problem ?
I need the same solution.
Can you post the mapping file and the java code ?
Thank you very much.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 22, 2005 1:08 am 
Regular
Regular

Joined: Fri Oct 01, 2004 2:19 am
Posts: 111
Location: Melbourne, Australia
Gavin,

First thanks for the informative reply. I'm looking forwards to seeing the
new doc version.

However, I've got another query related to your quotes below:

gavin wrote:
You should order things by truly *meaningful* information.

eg. use a set with order-by="createdDateTime"


gavin wrote:
Whenever the collection is flushed. Yes, you can rearrange elements and HB will update things correctly.


I need to be able to perform both actions - the ordered set of items
needs to be kept with the same order every time it is accessed,
and when being updated, the relative position of items in the list should
reflect the modified state (For the first case, imagine a stack that may
need to be popped, but until it happens the order cannot change; the
second case may involve the same 'stack' with the ability to remove
things in the middle).

What would the correct Hibernate construct/s to implement
these requirements be?

And if these need to be implemented using a list in Hibernate 3,
is my question 3 below still valid?

_________________
Cheers,

Bonny

please don't forget to rate :)


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