[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - JPQL issue - org.hibernate.QueryParameterException: could no
JoPe
do-not-reply at jboss.com
Tue Jun 3 22:05:31 EDT 2008
I am trying to execute two JPQL queries in an EJB3 application deployed on a JBoss 4.2.2.GA. The code looks as follows:
| String queryString1 = "select sub from Subscription sub where sub.itemPattern in (select ip from ItemPattern ip where ip.caption = :c)";
| List<?> queryResultList = em.createQuery(queryString1).setParameter("c", "myCaption").getResultList();
| String queryString2 = "select itm from green20.demo.items.Item itm where itm.persistenceID =:p";
| List<?> queryResultList2 = em.createQuery(queryString2).setParameter("p", 2).getResultList();
|
While the first query works fine, the second one results in the following error:
| org.hibernate.QueryParameterException: could not locate named parameter [p]
|
Even more strange: When I try to switch to a numbered parameter, like this
| String queryString2 = "select itm from green20.demo.items.Item itm where itm.persistenceID =?1";
| List<?> queryResultList2 = em.createQuery(queryString2).setParameter(1, 2).getResultList();
|
the error message stays the same and still complains about a named parameter:
| org.hibernate.QueryParameterException: could not locate named parameter [1]
|
This is also not affected by whether I pass the parameter value as int (2), String ("2") or Integer (new Integer(2)).
The only difference I can notice between the two queries is that in the second one I'm using a fully qualified name for the persisted Entity because the class is defined in a different package. Maybe Hibernate gets confused by that?
Can anybody give me a hint? I'm totally out of ideas.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4155531#4155531
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4155531
More information about the jboss-user
mailing list