File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Handling special character in HQL Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Handling special character in HQL" Watch "Handling special character in HQL" New topic
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
 
Threads others viewed
retrieve a single value inside string
Hibernate - update specific field with unique id
two queries combined together into a single one
Help with HQL
Hibernate Newbie, help on queries that do some grouping
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture