aspose file tools*
The moose likes Object Relational Mapping and the fly likes Sorting problem with HibernateSqlQuery with Websphere Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Sorting problem with HibernateSqlQuery with Websphere" Watch "Sorting problem with HibernateSqlQuery with Websphere" New topic
Author

Sorting problem with HibernateSqlQuery with Websphere

Ranjan Shri
Greenhorn

Joined: Jun 24, 2008
Posts: 3
Hi,

I am using Hibernate sql query to query some result set from database(Oracle 10G). Sql has orderby clause in it so that result are sorted by the sql itself.

Now the sql with sorting is working fine on Jboss, Weblogic. But on websphere sorting is not working though the results are same.

Thanks in advance.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What you say sounds very surprising. The container does't play any part in ordering of SQL results sets.

How do you sort your results? Can you show us the SQL you use and the code you call the query from?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ranjan Shri
Greenhorn

Joined: Jun 24, 2008
Posts: 3
Originally posted by Paul Sturrock:
What you say sounds very surprising. The container does't play any part in ordering of SQL results sets.

How do you sort your results? Can you show us the SQL you use and the code you call the query from?


I have a employee table having employeeid, employee name and address as it fields.
Sql being used is select employeeid, employeename, address from emplyoee order by 2 asc

Code is pretty stright forward
SQLQuery sqlQuery = createQuery(queryString);
where queryString is above mentioned query and createQuery is a private method which gets the SQLQuery object form HibernateSessionImpl

Returned resultset is not sorted correctly in websphere
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What does createQuery(queryString) do? Does it keep the column order as defined in your query? Using "order by 2" requires a fixed column order. What happens if you change this to "order by employeename", is the ordering more consistant?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sorting problem with HibernateSqlQuery with Websphere
 
Similar Threads
SQL Query
Hibernate 2: HQL "order by"
Which sorting is better, Code Level Vs Database level?
My query works fine at Oracle prompt..fails in JSP page
Hibernate Query taking long time