Re: Hibernate noob problem - Named query not known

From: Alan (nomorezpam3_at_hotmail.com)
Date: 08/20/04


Date: 20 Aug 2004 06:46:39 -0700

Think I found the solution, looking at the Hibernate private forums on
http://forum.hibernate.org/viewforum.php?f=1 ... Named Queries are
declared in the .hbm file with the format...

<query name="country.by_code">
<![CDATA[
from com.test.hibernate.mapping.Country where country_cd =
:country_cd]]>
</query>

I then call

try {
        Query query = session.getNamedQuery("country.by_code");
        query.setString("country_cd", code);
        return (Country)query.list().get(0);
}
finally {
        session.close();
}

Thanks anyway