I think the problem is less your query, more the method you are using on
HibernateTemplate. This should work for you:

public List<Category> getMaleCategories() {
      return getHibernateTemplate().find("from Categories
where male_only=?", Boolean.TRUE);
}

The named query form of the find method is used when you use named (as
opposed to positional) parameters in your query:

public List<Category> getMaleCategories() {
      return getHibernateTemplate().findByNamedParam("from Categories
where male_only= :maleOnly", "maleOnly", Boolean.TRUE);
}

Mike.


On 5/2/07, sionsmith <[EMAIL PROTECTED]> wrote:


Quick questions Guys & Girls - I'm new to hibernate 3 and unsure how to
write
the following in a query:

I have a Categories table in the DB, with a boolean flag as one of the
attributes, i want to return a list of all the items which have the
boolean
set to true. This is what i tried using, but it gave me an exception

public List<Category> getMaleCategories() {
       return getHibernateTemplate().findByNamedParam("from Categories
where male_only=?", "true", Hibernate.BOOLEAN);
}

I've tried by example object and that didnt seem to return the correct
set!

Any help would be very greatful :)

Many thanx Sion
--
View this message in context:
http://www.nabble.com/How-to-query-in-Hibernate-3-tf3680950s2369.html#a10287100
Sent from the AppFuse - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to