Hi I've just started learning Hibernate on my own, and I think I already understand the basics.
I've seen how to map the tables to POJO's where you can access the properties of the resulting objects with set/get methods.
But there's something I haven´t been able to find: when you implement a select with joined tables.
For example the simple case:
select t.town_name, s.state_name, t.population from towns t, states s where t.state_id = s.id and t.population<5000
The first thing I've thought is to implement a select on object Town where population<5000 and then for each object obtained impement another select on object State where S.id = town.getState_id()
this is easy, but if the select were more complicated with many tables joined it would be a mess. I'm sure that somehow hibernate must automate this, but I haven´t seen any clear examples.
Can anyone give me a hint about this?
Thanks.
|