How to order result of hibernate based on a specific order

前端 未结 6 1965
别那么骄傲
别那么骄傲 2021-01-07 19:15

I need to send a query to retrieve values that has a specific group of characters as following:

Lets say I am interested in \'XX\' so it should search for any field

6条回答
  •  孤独总比滥情好
    2021-01-07 20:11

    If you don't want to sort the result in memory,you can modify your criteria,I'll show you the SQL

    select * from table where fname like 'XX%' order by fname
    union all
    select * from table where fname like '% XX%' order by fname
    union all
    select * from table where fname like '% XX' order by fname
    

    the result will be your order and alphabetical and then apply your filter.

提交回复
热议问题