| Author |
Handling special character in HQL
|
Jigar Naik
Ranch Hand
Joined: Dec 12, 2006
Posts: 729
|
|
Hi,
I am building HQL dynamically as below.
But the problem i am facing is that the thatre city contains one single quote because of which my HQL is not getting build correctly.
Is there any way to handle this situation instead of manually escaping single quote ?
|
Jigar Naik
|
 |
Claudiu Chelemen
Ranch Hand
Joined: Mar 25, 2011
Posts: 62
|
|
Hi there,
First off, I don't think it's a good idea to concatenate holdOverSearchCriteriaTO.getTheatreCity() like this, wouldn't you rather be on the safe side and use bind parameters ?
Secondly, for the question at hand, you may use the escapeSql method from StringEscapeUtils to escape the problematic characters.
Cheers,
Claudiu
|
 |
Jigar Naik
Ranch Hand
Joined: Dec 12, 2006
Posts: 729
|
|
|
Thanks a lot.
|
 |
 |
|
|
subject: Handling special character in HQL
|
|
|