-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: SQL query
PostPosted: Wed Sep 14, 2005 5:03 am 
Newbie

Joined: Wed Sep 14, 2005 4:57 am
Posts: 10
the following sql is sent to the db using hibernate

From com.workpool.directory.Entry entry where (
entry.name like "%Nigeria' s%") OR (entry.refNo like "%Nigeria's%") and (entry.personal="No" or entry.author.id=3) order
by entry.name


If you do the query in sql it works and displays a result but in hibernate it throws an exception beacause of the apopstrophe. Is there any why to search with an apostrohe and still get the correct result and no exception. I have tried a / in front of the apostrophe and also double quotes.


thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 5:33 am 
Pro
Pro

Joined: Fri Sep 02, 2005 4:21 am
Posts: 206
Location: Vienna
How about passing %Nigeria's% as a parameter?

Erik


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 5:52 am 
Newbie

Joined: Wed Sep 14, 2005 4:57 am
Posts: 10
no it is a string value and therefore needs the double quotes aroud it.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 6:26 am 
Pro
Pro

Joined: Fri Sep 02, 2005 4:21 am
Posts: 206
Location: Vienna
meder wrote:
no it is a string value and therefore needs the double quotes aroud it.

Sorry but that's absurd - JDBC cares for things like that. Use ? as a placeholder , pass a parameter to the query and it will work.

Erik


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.