[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Hibernate query parameter
georgesberscheid
do-not-reply at jboss.com
Fri Dec 7 03:58:33 EST 2007
Hi,
I am having problems with rather simple Hibernate queries not returning the results I would expect when using query parameters:
| Account account = (Account) entityManager
| .createQuery("SELECT c.account FROM Customer c WHERE c.salesperson.name = :salesname")
| .setParameter("salesname", salesGuyname).getSingleResult();
|
-> 0 results (NoResultException)
However, it works if I don't use query parameters and create the query string with concatenation:
| Account account = (Account) entityManager
| .createQuery("SELECT c.account FROM Customer c WHERE c.salesperson.name = '" + salesGuyname + "'")
| .getSingleResult();
|
-> 1 result (the one I'm expecting)
I'm using JBoss 4.2.2 with MySQL 4.1. Does anyone have an idea where this could come from?
Thanks,
Georges
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4111128#4111128
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4111128
More information about the jboss-user
mailing list