HQL multiple where clauses

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);

Answer

Try this:

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

Hibernate Find method

Leave a Reply

Your email address will not be published. Required fields are marked *