I was originally doing a single variable query and I had to add in another variable to my statement and can't seem to get it to work correctly or find a straight answer on the expected syntax. I've already checked everything is mapped correctly and nothing null is going into the query.

Here's what I'm attempting to do which isn't working correctly

return getHibernateTemplate().find("from Pricing_Data where rate_class=?", rate_class + "where utility=?", utility);

Orginally I had it as this and that was working as expected

return getHibernateTemplate().find("from Pricing_Data where rate_class=?", rate_class);
有帮助吗?

解决方案

Try this:

return getHibernateTemplate().find("from Pricing_Data where rate_class=? AND utility=?", new Object[]{rate_class, utility});

Hibernate Find method

其他提示

Try to use query

from Pricing_Data where rate_class = ? and utility = ?

Then setParameter for rate_class and utility.

SQL/HQL queries can have second (third, etc) where clause only in subqueries.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top