How can we order a column as int using hibernate criteria API?

Posted by Satya on Stack Overflow See other posts from Stack Overflow or by Satya
Published on 2010-05-20T05:03:38Z Indexed on 2010/05/20 5:10 UTC
Read the original article Hit count: 284

Filed under:

Hi I want to fetch the data form data base using hibernate Criteria API.

That data should be ordered by some column as number.

This column is defined as varchar in DB. But I have to fetch as numberic.

I am facing problem using criteria API as it is ordering like string onyly.

Ex: I am getting data like

9, 8, 7, 6, 5, 4, 3, 2, 1,10

but i want data as

10,9,8,7,6,5,4,3,2,1

Is there any Hibernate methods to covert varchar to number like convert("some column",int ) or cast("some column",int) ?

© Stack Overflow or respective owner

Related posts about nhibernate