Hi:
I have a problem with my inheritance model: I have a hierarchical tree containing 64 subclasses in total. This in itself is not bad… Except if I try to execute a query on the parent of the tree. Hibernate generates joins to all child tables in the SQL, but I just want the data from the parent entity, not the children, and I don’t want so many joins, because the query is too big and slow…
for example:
class Person is a parent
class Worker is a child
class Work is the owner of a set of Person (a polimorfic set)
when I say, for example:
Person p = new Worker();
Work work = new Work();
work.getPeople().add;
session.save(work);
Then after the work object is persisted, if I want to obtain the people that work there:
Work work = (Work) session.get(Work.class,1);
work.getListPeople();
Which instructs Hibernate to generate join statements on Person and Worker tables to obtain the Person through Work.
If I don’t want Hibernate to generate a join statement on my child table, but rather I just want to obtain the data from the parent table, how can I do this?
Thanks in advance.
|