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.  [ 3 posts ] 
Author Message
 Post subject: Specifying the default order by column for a class
PostPosted: Tue Dec 16, 2008 5:24 am 
Newbie

Joined: Fri Sep 28, 2007 4:12 am
Posts: 15
I couldn't find anything anywhere so I assume this is not possible but anyhow.

Does anyone know of a way to specify the default ORDER BY column for a class in its mapping file?

*edit*
whoops, forgot to mention -> NHibernate 2.01 and MSSQL 2000 & 2005


The thing I would want to achieve is that if no ordering is used in the application, the query should be ordered by its primary key column(s) automatically.
In MSSQLits not guaranteed that the order is consistent if no ORDER BY clause is used in the query so I wanted to have some automatic way to make sure I at least have some consistent order that doesn't pose a performance bottleneck.

If that's not possible I may have to do some tweaking in the DAO classes but maybe this works in the .hbm files already.



Greets
mosi


Top
 Profile  
 
 Post subject: NHibernate Mapping and ORDER BY clause
PostPosted: Tue Dec 16, 2008 11:02 am 
Newbie

Joined: Tue Dec 16, 2008 10:24 am
Posts: 4
I'm not sure if this helps, but part of the following link discusses how to specify the order-by clause in your mapping file (See Section 6.2 of the following):

http://www.hibernate.org/hib_docs/nhibernate/html/collections.html


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 17, 2008 5:31 am 
Newbie

Joined: Fri Sep 28, 2007 4:12 am
Posts: 15
Its not exactly what I had in mind but thanks for the hint, maybe I'll can use that someplace else.

the ordering that I wanted to have was for something like a simple query, not a relation like a bag or the likes. In SQL the query would read like

Code:
select id, some_other_column from some_table


no order is requested in the above query so nhibernate should append an order by id for this case.

Code:
select id, some_other_column from some_table order by id


Maybe there is a way to tell NHibernate to do this in the mapping files.


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