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: Base index of a list
PostPosted: Wed Jun 13, 2007 10:20 am 
Beginner
Beginner

Joined: Tue Jun 06, 2006 4:47 am
Posts: 25
I have a list index column with a base of 1, and as such, when I read this into my list collection, I have an empty object at position 0.

Does anyone know if base is implemented and if so, how and where it is used.

Many thanks


Top
 Profile  
 
 Post subject: Re: Base index of a list
PostPosted: Thu Jun 14, 2007 8:07 am 
Senior
Senior

Joined: Thu Feb 09, 2006 1:30 pm
Posts: 172
stovesy wrote:
I have a list index column with a base of 1, and as such, when I read this into my list collection, I have an empty object at position 0.

Does anyone know if base is implemented and if so, how and where it is used.

Many thanks


This is not an NHibernate thing, but rather a CLR thing. NHibernate is simply mapping the index of the item in the collection to a column in the database so that when it is reloaded you can have the exact same collection you had before persistence.

There would be no way to have initially set the value to 1 as the base at the 0th entry in the list. It sounds to me like you are using the "index" column for something other than it is intended.

If that is the case consider using a dictionary (map) instead of a list. I think this is really what you want. You will then only have the number of items you requested. This is what we do when we have sequenced items which store their sequence values starting at a base of 1 (or any base really I guess).

Let me know if I misunderstood your issue.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 14, 2007 8:23 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
It's not possible in NHibernate 1.2 currently, but it's very easy to add. Maybe you could contribute?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 14, 2007 9:23 am 
Beginner
Beginner

Joined: Tue Jun 06, 2006 4:47 am
Posts: 25
sergey wrote:
It's not possible in NHibernate 1.2 currently, but it's very easy to add. Maybe you could contribute?


Will if it's a worthwhile addition, then I'll give it a go.

I've no real clue as to where to look and how to start, so, can you give me any pointers Sergey as to the best way to implement this.

Many thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 14, 2007 10:57 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
The best way would be to take a peek at Hibernate (Java) source code. There is class AbstractCollectionPersister (or maybe BasicCollectionPersister, don't remember now) which has a field called baseIndex or some such. Find where it's set and used and port the relevant code over.


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.