[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3215) query with hibernate id for composite keys,and positional parameters do not work

telicki (JIRA) noreply at atlassian.com
Thu Apr 3 07:52:33 EDT 2008


query with hibernate id for composite keys,and positional parameters do not work
--------------------------------------------------------------------------------

                 Key: HHH-3215
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3215
             Project: Hibernate3
          Issue Type: Bug
          Components: query-hql
         Environment: hibernate3.jar, oracle db
            Reporter: telicki


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 at 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

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list