-->
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.  [ 2 posts ] 
Author Message
 Post subject: a query issue
PostPosted: Fri Oct 17, 2003 8:14 pm 
Beginner
Beginner

Joined: Wed Sep 17, 2003 10:25 am
Posts: 36
Hi,

I am having a little query issue that I am sure someone here has faced/resolved. It is really simple. What should I do using the Query interface to do a select using a wildcard '%'?

I am doing this

Query q = session.createQuery("Select count(*) from persistClass as pc where name like %?%");
q.setString(0, "am");


I also tried this:
Query q = session.createQuery("Select count(*) from persistClass as pc where name like %:name%");
q.setString("name", "am");

Both are failing? What is wrong with this syntax?

Thanks...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 17, 2003 9:37 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Code:
Query q = session.createQuery("select count(*) from persistClass as pc where pc.name like :name");
q.setString("name", "%am%");


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