[OJB-developers] n:m-Mapping with Extent
Brought to you by:
thma
From: <Joa...@tp...> - 2002-04-29 13:04:53
|
Hy, it's me again. I've finally hunted down the bug. Let me explain the scenario: I've got a class OneSide. Each object can have one or more ManySide objects. This is implemented via a List with coresponding CollectionDescriptor using a association-table (non-decomposed N:M-Mapping in OJB-speak). Additionally there is a class named ManySideExtent, that extends ManySide and is mapped to another table. When I enable debugging in SqlGenerator I'll find the following messages (after many others) when loading a OneSide object: [ojb.broker.accesslayer.SqlGenerator] DEBUG: SQL: SELECT manyside.id,manyside.value FROM manyside, oneside_manyside WHERE (oneside_id= ? ) AND oneside_manyside.manyside_id=manyside.id this one looks quite correct and gets me the correct results (all ManySide objects that belong to the one OneSide object), but the next one (which tries to load the ManySideExtent objects) fails: [ojb.broker.accesslayer.SqlGenerator] DEBUG: SQL: SELECT manyside_extent.id,manyside_extent.value,manyside_extent.another_value FROM manyside, oneside_manyside WHERE (oneside_id= ? ) AND oneside_manyside.manyside_id=manyside.id the problem here obviously is, that the wrong table is used in the FROM-clause and the WHERE-clause. These come from the Query object, that is created by the PersistenceBrokerImpl in getMtoNQuery. I think calling getMtoNQuery with the ClassDescriptor of ManySideExtent for the second query would solve the problem, the problem is, that the query is not built in the function that decides wether we need to query for extents ... Maybe a correct solution would be somewhere else altogether, but I don't know enough about the system to see where. regards Joachim Sauer |