-->
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.  [ 1 post ] 
Author Message
 Post subject: How do I mimic ORDER BY CONVERT(int, field) in criteria?
PostPosted: Thu Jun 14, 2007 6:28 am 
Newbie

Joined: Mon Sep 18, 2006 6:34 am
Posts: 18
Hibernate version: 3.2

Name and version of the database you are using: MS SQL Server 2000 SP4

Hi,

does anyone know how I would mimic an ORDER BY CONVERT(int, field) statement using the Hibernate criteria interface?

I have a lookup table with codes and descriptions such as:

Code Description
1 Desc 1
2 Desc 2
10 Desc 10

Both fields are strings so when a query runs to retrieve data from the table it's done so alphanumerically instead of numerically so results are 1, 10, 2.
Using the CONVERT(int, Code) I can get 1, 2, 10.

Is there any way of doing this or will i have to create a named query in the mapping file to support the ORDER BY?

Thanks,
John


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.