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.  [ 4 posts ] 
Author Message
 Post subject: map order-by exception
PostPosted: Sun Jun 03, 2007 10:16 am 
Newbie

Joined: Sun Jun 03, 2007 10:09 am
Posts: 1
I've just started using NHibernate 1.2 and I've a problem using <map> tags.

I tried to write this in my hbm.xml file:
...
<map name="BookMarks" lazy="false" order-by="Id">
...

and I continue gettin the same exception:
Could not compile the mapping document: Pirobox.BusinessLayer.BookMark.PbBookMarkDirectory.hbm.xml ---> NHibernate.MappingException
: Cannot use order-by with generic map, no appropriate collection implementation is available

I have understood that the problem is with the the order-by clause, infact if I remove it everything works correctly. My question is (eventually), shouldn't NHibernate manage "order-by" for map tags? In the faqs I read that it should use internally the ListDictionary collection. Am I missing something?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 13, 2007 7:14 am 
Beginner
Beginner

Joined: Fri May 25, 2007 5:55 am
Posts: 26
Hi Pirobox,

I have seen this error too. Is it not supported in NHibernate. I have tried using the sort="natural" as well in the mapping and it complains about that too. Let me know how you got on.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 13, 2007 9:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
A dictionary/hashtable is by definition unordered; one gets access to an element by specifying a key like this:
Code:
value = dictionary[key];

Therefore, specifying "order-by" for a <map> does not make much semantical sense. If the order of items is important, consider using a different mapping strategy like a <list>.

_________________
Karl Chu


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 14, 2007 7:12 am 
Beginner
Beginner

Joined: Fri May 25, 2007 5:55 am
Posts: 26
Fair point. There is a ListDictionary though.

In any case what you are saying is correct.


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