[edit]From the API:
The Integer class wraps a value of the primitive type int in an object. An object of type Integer contains a single field whose type is int.
In addition, this class provides several methods for converting an int to a String and a String to an int, as well as other constants and methods useful when dealing with an int.
http://plainoldjavaobject.blogspot.in
Jayesh A Lalwani wrote:In your Order by clause, you will need to put a call to a database function that converts the string to Integer. You can create your own Order class like this http://blog.tremend.ro/2008/06/10/how-to-order-by-a-custom-sql-formulaexpression-when-using-hibernate-criteria-api/
Conversion functions are usually database specific. So, you might end up putting database specific code in here. I am not sure how to make a database agnostic custom Order class here. Might be possible but you will need to understand the API very well.
However, the query that it will generate will perform horribly. You are better of changing the datatype of the database column if possible. If it stores Integers make it Integer.
Lalit Mehra wrote:yes you can use the Integer wrapper class to cast it back to an integer ...
try this ... java.lang.Integer
[edit]From the API:
The Integer class wraps a value of the primitive type int in an object. An object of type Integer contains a single field whose type is int.
In addition, this class provides several methods for converting an int to a String and a String to an int, as well as other constants and methods useful when dealing with an int.
Have added quote tags, because most of this post was a direct quote. Please always cite the source for every quote.
CR
[/edit]
Campbell Ritchie wrote:Welcome to the Ranch
![]()
That is ascending order, just not numerical order. It looks like what is jocularly called asciibetical (pronounced aski----). It looks as if your numbers were being turned into Strings somewhere. Or maybe you are starting off with Strings.Does storeNumber represent the name of the column? Are you getting those Strings from XML or similar? You are doubtless familiar with the usual techniques for parsing Strings to ints and similar, but you can’t cast a String to an int.
Jayesh A Lalwani wrote:Whoa! You are sorting the result set in Java?! Unless you are working with very small data sets, it sounds like you are asking for trouble
joke time: What is brown and sticky? ... ... ... A stick! Use it to beat this tiny ad!
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
|