-->
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: HQL query and databinding problems
PostPosted: Fri Sep 30, 2005 7:53 am 
Newbie

Joined: Wed Sep 28, 2005 3:44 pm
Posts: 5
I need to search the table using HQL. I need to specify the '%" constraint for selection of other matching records.

I am trying:
Code:
session.Find ( "Select st.Id from Store as st Where st.Name like " + strSearchCriteria +" OR st.Zipcode=" + strSearchCriteria +"" );


Also when I bind the arraylist to my datagrid, I can see just the Id column. If I take one more field in my query, the grid distorts and some properties are displayed ??

Can anyone guide me on this. Where am I going wrong ??


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 12:09 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
For your HQL, try:

Code:
session.Find ( "Select st.Id from Store as st Where st.Name like %" + strSearchCriteria +"% OR st.Zipcode=" + strSearchCriteria );


Note that you should really use parameters here! (read IDataParameters vs plain text queries)

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 03, 2005 9:36 am 
Newbie

Joined: Thu Sep 08, 2005 12:15 pm
Posts: 17
If you want more than one column you may try something like this

Code:
session.Find ( "Select st from Store as st Where st.Name like %" + strSearchCriteria +"% OR st.Zipcode=" + strSearchCriteria );


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.