-->
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.  [ 5 posts ] 
Author Message
 Post subject: Collection indexed from another table (or object property)?
PostPosted: Mon Dec 12, 2005 5:20 pm 
Senior
Senior

Joined: Thu Jun 02, 2005 5:03 pm
Posts: 135
Location: Paris
I've got a collection that I want to have sorted by a field of another table to which it is related (which maps as a property of another object, incidentally).

I've been trying to work out how this can be done, but the <map> collection mapping allows for <index>, which sorts on a column in the table the collection refers to, or <index-many-to-many> which seems to be for sorting by types (?!) which I can't figure out.

In essence, what I'm trying to do is something like the following:

Code:
<map name="ModuleParameterSets" table="ModuleParameterSets" lazy="true" >
   <key column="ProcessID" />
   <index column="ModuleIndex" />
   <one-to-many class="ModuleParameterSet" />
</map>


...where from the above the index column is found in the Modules table, not the ModuleParameterSets table.

Can something like this be done? I've seen references to foreign-key attributes in the mapping schema, but I can't figure out how to do this.

Help?

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 13, 2005 5:04 am 
Regular
Regular

Joined: Fri Jun 11, 2004 6:27 am
Posts: 81
Location: Yaroslavl, Russia
You should rethink your requirements: map is in fact a hashtable which can not be considered as a sorted collection. And index of the map is used for a key in this hashtable.

_________________
Best,
Andrew Mayorov // BYTE-force


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 13, 2005 5:11 am 
Senior
Senior

Joined: Thu Jun 02, 2005 5:03 pm
Posts: 135
Location: Paris
Ok, fair enough, however I'm not stuck on map.

My essential requirement is a collection that can be reorganized based on values from a collection mapped to another table. I don't want to replicate the ordering values between the two tables as they could potentially become out of synch.

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 13, 2005 6:09 am 
Regular
Regular

Joined: Fri Jun 11, 2004 6:27 am
Posts: 81
Location: Yaroslavl, Russia
I don't exactly realize your database structure and classes mapping, but maybe mapping of the collection to a view will help? In this view you can combine association table with sort field. You will need triggers for update and insert records in the view, though (INSTEAD OF, to be correct).

_________________
Best,
Andrew Mayorov // BYTE-force


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 13, 2005 7:04 am 
Senior
Senior

Joined: Thu Jun 02, 2005 5:03 pm
Posts: 135
Location: Paris
Ah, fantastic idea! *slaps forehead*

Fortunately the collection I'm talking about will be read only, so there's no need to deal with updates.

Thanks xor!

Cheers,

Symon.


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