-->
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.  [ 1 post ] 
Author Message
 Post subject: Using wildcards in named parameters
PostPosted: Thu Jun 28, 2007 7:43 am 
Newbie

Joined: Mon Sep 04, 2006 1:27 pm
Posts: 9
Hi,could somebody put an example of how to use a wildcard % with named parameters,I know do it in a SQLQuery
String sql = "select * from tablename where fieldname1 like ? ;
SQLQuery query = session.createSQLQuery(sql);
query.addEntity(classname.class);
query.setString(0,"%"+fieldname1+"%");
that's work fine
but I want to do it with named paramaters,where we have to put the % wildcard?
String queryString = "from " + classname.class.getName() + " e where e.nombre like :nombre ";
List list = hibernateTemplate.findByNamedParam(queryString,"nombre", nombre);
return list;
}

If we put the widcards inside the String of the query eg where e.field like :nombre%";
throws an unexpected '%'
Also I tested put in hibernateTemplate.findByNamedParam(queryString,"%nombre%", nombre);
throws an cannot locate named parameter [%nombre%].

Can we use wildcards with hibernate named parameters??


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

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.