Criteria use an aggregate function in order

I have one criterion, and I stuck to the following:

I use a sql server, so on my SQL server I have the following condition (Note: I do not put the whole query here. I just put my order by by).

order by (IIF(LEN(Code) = 1, '0'+Code ,Code))

"Code" is my column name. Now I want to implement it in sleep mode in the following

criteria.addOrder(Order.asc("CTC.code"));

Please help me achieve this. Any help would be appreciated.

+2
source share
1 answer

After spending too much time and searching on Google, I found a working solution from here:

http://blog.tremend.ro/2008/06/10/how-to-order-by-a-custom-sql-formulaexpression-when-using-hibernate-criteria-api/

, , , .

+1

Source: https://habr.com/ru/post/1781681/


All Articles