-->
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: 'order by' does not work with postgres db
PostPosted: Wed Jun 15, 2005 8:36 am 
Regular
Regular

Joined: Fri Feb 25, 2005 3:02 am
Posts: 71
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

[b]Hibernate version:3.0[/b]

[b]Mapping documents:[/b]

[b]Code between sessionFactory.openSession() and session.close():[/b]

[b]Full stack trace of any exception that occurs:[/b]

[b]Name and version of the database you are using:postgresql 8.0[/b]

[b]The generated SQL (show_sql=true):[/b]

[b]Debug level Hibernate log excerpt:[/b]

Hi, am using hibernate with postgresql database. When I do a simple query such as "select * from User u order by u.name", I don't get an orderd result set. When I see the sql generate by hibernate it does put the 'order by' clause in the select statement, but my results are not ordered. I copy and paste the generated sql from hibernate in my postgresql db, I got an ordered results. Is there a problem with hibernate and postgres with 'order by' clause. I would also like to know if the problem occurs before Hib. sends the select statement to the db or after it has been executed in postgres and then Hib. fails to display the results in order.

thanks in advance[/b]


Top
 Profile  
 
 Post subject: RE:'order by' does not work with postgres db
PostPosted: Thu Jun 16, 2005 3:30 am 
Newbie

Joined: Thu Jun 16, 2005 3:24 am
Posts: 1
Can you copy and paste code please ?

after you do Query in HQL you get a Query object you know , and it has a list() method which return "ordered" list.

When you iterate this list you see that results are ordered.

Query query = ses.createQuery("select test from com.afsinbey.Test as test where test.x = ? order by test.kod");

and after this :

List l = query.list();
System.out.println(" Result 0 : " + l.get(0));
System.out.println(" Result 1 : " + l.get(1));


Mehmet.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 3:38 am 
Regular
Regular

Joined: Fri Feb 25, 2005 3:02 am
Posts: 71
In fact I found my error. when I parse the list I put my object in a hashset which I should not.


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.