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.  [ 3 posts ] 
Author Message
 Post subject: Problem with 'setParameter'
PostPosted: Thu Sep 15, 2005 9:23 am 
Newbie

Joined: Mon Jun 13, 2005 2:39 pm
Posts: 7
Hi. I've been having a problem with 'setParameter'. I'm trying to filter a table by read-in 'affiliateID'. When I used setParameter within a very similar method, it worked fine. I would appreciate any tips or suggestions on this problem.

Hibernate version: 3.0

Code between sessionFactory.openSession() and session.close():
Movie theMovie = new Movie();
Session s = factory.openSession();
Transaction tx = s.beginTransaction();

//Retrieving data from DB
List test = s.createQuery("from Theatre").list();
Query q = s.createQuery("from Theatre t where t.affiliateID = :affiliateID");

q.setParameter("affiliateID",affiliateID);

List theAffiliateMovieList = q.list();

s.flush();
tx.commit();
if (s != null){
s.close();
}

Full stack trace of any exception that occurs:

The method setParameter(int, Object, Type) in the type Query is not applicable for the arguments (String, int)

Name of the database:MySQL


Top
 Profile  
 
 Post subject: Use query.setInteger(String,int)
PostPosted: Thu Sep 15, 2005 9:34 am 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
The variable affiliateID is an int, so use query.setInteger(String,int).
Read the javadoc before posting, please.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 9:56 am 
Newbie

Joined: Mon Jun 13, 2005 2:39 pm
Posts: 7
Thanks a lot. I will read the javacod more carefully next time.


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