Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.1
i have a class Foo that maps a single table in the database. all works well. Foo has a subordinate table, Bar. the DBA has provided a view that i map to FancyFoo. FancyFoo has all the Foo data plus some info from the 'latest' Bar associated with a specific Foo.
i've created a FancyFoo java object that extends my Foo java object, and i've copied Foo.hbm.xml to FancyFoo.hbm.xml, adding the extra attributes.
problem: i get duplicate results. for instance, my old query:
Code:
select count(foo) from Foo foo where foo.name like 'ZASU PITTS'
which used to return a count of
one, now returns a count of
two, even though there is only one ZASU PITTS.
from my trace, i can see what happens - sort of. in hibernate's HQLQueryPlan.performList method, i end up with two translators, one for Foo and one for Fancy Foo. the first one has the HQL:
Code:
select count(foo) from Foo foo where foo.name like 'ZASU PITTS'
and the other has:
Code:
select count(foo) from FancyFoo foo where foo.name like 'ZASU PITTS'
HQLQUeryPlan.performList runs each, and they both return a
one, since they both successfully find ZASU PITTS, and then HQLQueryPlan combines the results - and the answer is
two.
so, er, what is the proper way to do inheritance? or how do i get hibernate to not combine results?