-->
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.  [ 1 post ] 
Author Message
 Post subject: bug in Query with ?
PostPosted: Thu Apr 03, 2008 2:56 am 
Newbie

Joined: Thu Apr 03, 2008 2:45 am
Posts: 1
I'm executing this query:

Query query = sess.createQuery( "
from Car as Car
where Car.id=?");
query.setParam(0,carPK);

where id is Hibernate pk identifier, and value of ? is Object that represents composite primary key.

The following exception occures:


org.hibernate.QueryException: Expected positional parameter count: 1, actual parameters: [dataaccess.crud.hibernate.CarPk@5b35] [from Car as Car
where Car.id=?
]
at org.hibernate.impl.AbstractQueryImpl.verifyParameters(AbstractQueryImpl.java:319)
at org.hibernate.impl.AbstractQueryImpl.verifyParameters(AbstractQueryImpl.java:275)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:75)
at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:811)
at
(...)

if I change the query to


Query query = sess.createQuery( "
from Car as Car
where Car.id=:param1");
query.setParam("param1",carPK);

and use the same object as value of param1, everything is ok


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.