View Single Post
Old 03-18-2011, 11:40 AM   #9
photon
The new goggles also do nothing.
 
photon's Avatar
 
Join Date: Oct 2001
Location: Calgary
Exp:
Default

Quote:
Originally Posted by psyang View Post
Bottom line - it's a very poor query structure and even the fact that it is auto-generated isn't much of an excuse. I'd expect even an auto-generated query could come up with something more like:

Code:
select count(cat) from cat, animal, house_animal, house where
  cat.id = animal.id and
  animal.id = house_animal.animal_id and
  house_animal.house_id = house.id and
  house.id = 10690
That's probably because of the actual HQL query I have to use.

I'm using Hibernate, and because I'm only caring about the house-animal relationship from the house side of things, I had to generate a query in Hiberate like:

"SELECT count(c) from Cat c, House h WHERE c member of h.cats and h.id = :tid"

using HQL, Hibernate's query language, which refers to things at an object level, I don't have access to the house_animal table at the HQL level (unless I create my own relationship object HouseAnimal, which is what I will do).
photon is offline   Reply With Quote