Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Problem with Parameters in Hibernate query  RSS feed

Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, can someone please assist!:

I have the following query, the problem is in the way I'm setting parameters for the query (eg. queryObject.setParameter), the query otherwise works well with a single parameter.

public Company findPopulatedCompanyByName(final String name, final String name_other) {
HibernateCallback callback = new HibernateCallback(){

public Object doInHibernate(Session session) throws HibernateException, SQLException {
Company Company =null;
String query = "from Company g where IN (?,?)";
Query queryObject = getHibernateTemplate().createQuery(session, query);
queryObject.setParameter(0, name);
queryObject.setParameter(1, name_other);
Company = (Company) queryObject.list().get(0);
return Company;


return (Company) getHibernateTemplate().execute(callback);

Many thanks.
Posts: 17344
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aslam, please click the My Profile link and change your name to follow JavaRanch's naming policy, which states that a real first and last name must be used. Jessica has already asked you to do this.


His brain is the size of a cherry pit! About the size of this ad:
how do I do my own kindle-like thing - without amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!