• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with Parameters in Hibernate query

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 g.name IN (?,?)";
Query queryObject = getHibernateTemplate().createQuery(session, query);
queryObject.setParameter(0, name);
queryObject.setParameter(1, name_other);
Company = (Company) queryObject.list().get(0);
Company.getUsers().size();
return Company;
}

};

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

Many thanks.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

Thanks

Mark
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic