Parameter in like clause JPQL

后端 未结 8 1325
盖世英雄少女心
盖世英雄少女心 2020-11-27 03:20

I am trying to write a JPQL query with a like clause:

LIKE \'%:code%\'

I would like to have code=4 and find

455
554
646
...
         


        
8条回答
  •  春和景丽
    2020-11-27 04:17

    If you do

    LIKE :code
    

    and then do

    namedQuery.setParameter("code", "%" + this.value + "%");
    

    Then value remains free from the '%' sign. If you need to use it somewhere else in the same query simply use another parameter name other than 'code' .

提交回复
热议问题