permaculture playing cards*
The moose likes Object Relational Mapping and the fly likes org.hibernate.QueryException: Expected positional parameter count: 2, actual parameters: [1] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "org.hibernate.QueryException: Expected positional parameter count: 2, actual parameters: [1] " Watch "org.hibernate.QueryException: Expected positional parameter count: 2, actual parameters: [1] " New topic
Author

org.hibernate.QueryException: Expected positional parameter count: 2, actual parameters: [1]

subodh joshi
Ranch Hand

Joined: Apr 09, 2010
Posts: 41
i am using Named Query in my Project Like this
Query query = session.getNamedQuery("selectedPortfolioInfo");
query.setInteger(0, portfolioId);
query.setInteger(0, userID);
List getData = query.list();

and *.hbm.xml file entry is like this
<query name="selectedPortfolioInfo">from PfPortfolioInfo Where id.pfpiId=? And id.umulUserId=? </query>

But i am getting Exception
org.hibernate.QueryException: Expected positional parameter count: 2, actual parameters: [1]

Both id.pfpiId And id.umulUserId both are composite key columns in database table

Thanks For help
Amit Vinod Dali
Ranch Hand

Joined: Apr 14, 2010
Posts: 42
Please check the positions of the parameters you are passing;

query.setInteger(0, portfolioId);
query.setInteger(0, userID); query.setInteger(1, userID);

subodh joshi
Ranch Hand

Joined: Apr 09, 2010
Posts: 41
Sorry i was wrong and wasted the group members time in the simple issue..


thanks again
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: org.hibernate.QueryException: Expected positional parameter count: 2, actual parameters: [1]
 
Similar Threads
JPA native Query - Select... where... IN, How to set list of values to setParameter()?
Hibernate and DB2 stored procedure
@ManyToMany delete problem
Hibernate Query Language Question (simple)
HibernateTemplate.find Long array vs Object array