How to tell oracle to sort by a specific sort order passed in from java?

前端 未结 5 629
长情又很酷
长情又很酷 2021-02-04 18:32

Here\'s what I need to be able to do.

I have a List in java which I can convert to comma separate string of IDs like so \"3,4,5,6,1,2\"

I wonder if there\'s way

5条回答
  •  独厮守ぢ
    2021-02-04 19:00

    In hibernate u can do -

    public String getResult(String sortOrder){
        SQLQuery query = getSession().createSQLQuery("select t from ( select t.id t from t_test t order by t.id=:sortOrder").addScalar("name", Hibernate.STRING);    
        query.setString("sortOrder", sortOrder);
        return (String)query.uniqueResult();
    }
    

提交回复
热议问题