How to specify a JPA named parameter surrounded by wildcards?

Solution 1:

How about

Query q = 
  em.createQuery(
    "SELECT x FROM org.SomeTable x WHERE x.someString LIKE :someSymbol"
);
q.setParameter("someSymbol", "%someSubstring%");

I'm pretty sure I once solved your problem like that.

Solution 2:

For reference, you could also use CONCAT:

like CONCAT('%', :someSymbol, '%')

Solution 3:

query.setParameter(someSymbol, "%" + someSymbol+ "%");