Liferay custom-sql using IN operator

前端 未结 1 1262
猫巷女王i
猫巷女王i 2021-02-10 22:03

I am using Liferay 6.1, Tomcat and MySQL. I have a custom-sql sentence for a list portlet. The custom-sql uses two parameters: an array of groupIds and a result limit.



        
1条回答
  •  梦毁少年i
    2021-02-10 22:43

    Perhaps hibernate is quoting your string of groupIds (presumably it is in the form of "1,2,3,4" and when hibernate translates this to sql it is putting quotes around it for you?

    You may want to try something like this (from Liferay itself):

    String sql = CustomSQLUtil.get(FIND_BY_C_C);
    
    sql = StringUtil.replace(sql, "[$GROUP_IDS$]", groupIds);
    

    And include ([$GROUP_IDS$]) in place of the (?) in your SQL

    0 讨论(0)
提交回复
热议问题