سؤال

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