Convert string to int in Hibernate order criterion

后端 未结 2 1085
没有蜡笔的小新
没有蜡笔的小新 2021-02-06 09:57

Basically, my question is the same as this one, but for Java\'s (JBoss) Hibernate: How can we order a column as int using hibernate criteria API?

I want to create an or

2条回答
  •  伪装坚强ぢ
    2021-02-06 10:39

    If the column contains integer values, the best solution is to map it as an integer rather than a String.

    If, for obscure reasons, this is not possible, you could add a integer field annotated with @Formula("cast(id) as number") in your entity and order on this field.

提交回复
热议问题