Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Search Exception for Cote d'Ivoire

 
sankey jain
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Both the below codes do the same operation, a country is got , and once we determine that the country is not null. a criteria is added.
Code Fragment 1 Works, But in this i am actually appending a SQL

reason Code 1 was done, Code 2 did not work for One Country " Cote d'Ivoire, EVen after escaping the single quote, it wont budge, there were no search results returned.

Any suggestions on how to get code 2 working ?

Code Fragment 1
-----------------------

Code Fragment 2
 
sankey jain
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any suggestions please
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

ConflictUtil.handleSingleQuoteInCriteriaForSQL(criteria.getCountryCategory());

What's going on here? If you bind a parameter you do not need to handle special characters.

 
sankey jain
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Sturrock wrote:

ConflictUtil.handleSingleQuoteInCriteriaForSQL(criteria.getCountryCategory());

What's going on here? If you bind a parameter you do not need to handle special characters.



It is replacing single quote with double quotes. when i dont handle it, it throws an SQL grammar exception.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like I said, you don't need to do this if you bind the parameter. My guess is after you have altered the search criteria Hibernate searches on the altered value.
 
sankey jain
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Sturrock wrote:Like I said, you don't need to do this if you bind the parameter. My guess is after you have altered the search criteria Hibernate searches on the altered value.


Okay, then i shall remove it, and try it with the original one.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic