File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Problem with Parameters in Hibernate query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Problem with Parameters in Hibernate query" Watch "Problem with Parameters in Hibernate query" New topic
Author

Problem with Parameters in Hibernate query

M Aslam
Greenhorn

Joined: Jul 12, 2004
Posts: 14
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.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with Parameters in Hibernate query
 
Similar Threads
Hibernate error
Hibernate Date Issue
Controlling Hibernate Session with Spring
Issue in annotating DAO using spring 3.0
SQLQuery not working