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.  [ 3 posts ] 
Author Message
 Post subject: How to use Like operator?
PostPosted: Mon Jul 03, 2006 2:44 pm 
Newbie

Joined: Mon Jul 03, 2006 2:38 pm
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

How to use LIke operator:


Dear All,

I want to query about how to use like operator in NHibernate.

"objLookupValueBO.HeadId.Head Like :varHead". I want to embed it with a percentage % sign as in SQL. but i cant know how to do it. Some class fellow has told me to use SEPARATE_PERCENTAGE. BUT I dont know exactly how to use it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 04, 2006 11:18 am 
Beginner
Beginner

Joined: Mon Jul 26, 2004 4:29 pm
Posts: 45
Location: TX, USA
Hi,

From section 15.8 of the reference manual (ver 3.0.5):

Quote:
Scalar SQL functions supported by the underlying database may be used


Code:
from DomesticCat cat where upper(cat.name) like 'FRI%'


Hope this helps,


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 04, 2006 5:44 pm 
Regular
Regular

Joined: Wed Jun 21, 2006 3:13 pm
Posts: 110
This is hokey, but here's one way to do it with a parameterized query:

Code:
string sql = "from Account where Username like :username";
IQuery query = DbSessionContext.Current.Session.CreateQuery(sql);
query.SetString("username", username + '%');


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.