How to set parameters within '' in EJB query

1k Views Asked by At

In EJB query, it's recommended to use setParameters() instead of concatenating string parameters in order to avoid SQL injection attack.

My question is: how to set parameters within '' in SQL update statements with 'SET':

String basicQuery = "update some table set somecolumn = ':para'";
Query query = em.createQuery(basicQuery);
query.setParameters("para", someString);

The runtime complains that it cannot locate parameter "para". Any workaround is appreciated.

1

There are 1 best solutions below

2
On

Remove the single quotes around :para.