I am using jpa with openjpa and i have table with varchar that represent as int in object.
column: "TRIES_ERR" (varchar)
Entity:
public class Book implements Serializable{
int triesErrAsInt;
String eMail
@Column(name="TRIES_ERR")
public int getTriesErrAsInt() {
return triesErrAsInt;
}
public void setTriesErrAsInt(int triesErrAsInt) {
this.triesErrAsInt = triesErrAsInt;
}
@Column(name="EMAIL")
public String getEMail() {
return eMail;
}
public void setEMail(String string) {
eMail = string;
}
}
I try to write a query with order by TRIES_ERR
but as int
and not as varchar
.
I have to use jpql (and not native query)
This is my query that I try and didn't work:
SELECT x
FROM Book x
ORDER BY x.triesErrAsInt ASC
returned rows are ordered as varchar and not as integer
I get as result: 12,13,14,2,3 instead 2,3,12,13,14