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.  [ 2 posts ] 
Author Message
 Post subject: using <List> collection with index column
PostPosted: Wed Jul 05, 2006 7:34 am 
Beginner
Beginner

Joined: Tue Feb 28, 2006 3:16 am
Posts: 28
I have following type of mapping in one of the mapping file, this is part of the mapping file about which i need help

<list name="Nodes" lazy="true" cascade="all-delete-orphan" inverse="true " >
<key column="ParentID" />
<index column="Pos" />
<one-to-many class="MyNewBagHierarchyWork.NodeRelation, MyNewBagHierarchyWork" />
</list>

I am able to get the collection of nodes, suppose there are 3 NodeRelation object in the collection , i want to swap object at position 2 to object a position 1. I have "pos" column in my datatable which represents index starting from 0. So if i swap the nodereatlion objects it should refelected in the database.

I m not able to swap the position of NodeRelation object


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 05, 2006 9:18 am 
Regular
Regular

Joined: Tue Feb 07, 2006 4:27 pm
Posts: 69
I'm a database guy and have some experience with NHibernate.

If I'm reading your question correctly you want to control the physical order that records are stored in the database.

This is something some databases support (clustered index in SQL Server). but once a table is created and records are saved, unless you dump the table contents and reload it, you cannot change the physical position records are saved in the DB.

In your query you can control the order records are read out of the DB using a standard 'Order By' clause and you can use your "pos" column as the 'Order By' argument.

In the end, it should not really matter what order the records are physically written to the DB as you can control this using standard SQL syntax and NHibernate supports the ordering of records returned.

Thanks


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