• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Special characters in hql

 
Ryan Waggoner
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

I have a bunch of hql statements that my site uses. Often these queries are made from input on the web page. For something like a description field it is not unusual to have an apostrophe (') in the query. SQL does not like this one bit, and yells at me for it every time.

Any suggestions on how I would go about putting an escape character in for an ' every time it appeared in the query?

(with out putting an if statement on each hql statement )

Thanks!
 
Reehan Lalkhanwar
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Append a special character before the quote and tell the DB that as the escape character.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use parameter binding.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic