Multiple reverse collections.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Multiple reverse collections.

Stephane Passignat
Hello,

I have a case I can't fix in openjpa.



When a class (Product) have 2 collections (I only checked with reversed mapping) of concrete objects (one of MecanicalFeature and one of ElectricalFeature) inheriting from a common class (Feature), finding an existing Product fails (return null).



Here is a class diagram : http://www.plantuml.com/plantuml/png/SoWkIImgAStDuKhEIImkLWWeoayfJIw1yjnI4qjAYrAXFD_KvCIypEJ475HXrvpKv98YP74kT9KAkherTd3J81fmIaET01IqKr3IKbB0CCnAGIaN9bQiXA4UOZoQXbIm85I7GsfU2j3B0000



Here is the ER diagram

http://www.plantuml.com/plantuml/png/RSvFIyCm60Rm-_ifNkTb0SVk4iF6ia9FokpE8pNlR31fI_v0Y_ZTLLhR2iijvFSyUNOXAX-Jit2dwMfgmgXAI-kEuPjL8M27dEEwUBZFiltFOIZ4H5jldFBzvOFwtm0l1K-Yuzia-BQSsRNnPDxhYPa5Cm8gemaTnQhHORY4I9wQsBSK08OzBwTdUJuK33y1__sRImPV8ygE--9yEjv6Y39_FG0kv_pLNeQMCO-RZS3nvN4rawTShc17jKxEVWC0





The entityManager.find generates the following SQL (I replaced useless columns by *) :


SELECT t0.*,

       t3.*

FROM Product t0

       LEFT OUTER JOIN Feature t3 ON t0.id = t3.PRODUCT_ID

WHERE (t3.disc IS NULL OR t3.disc IN ('Mecanical'))

  AND t0.id = 0

ORDER BY t3.PRODUCT_ID ASC




The eager fetching on those collections consider only one collection or only one type of concrete class. A solution would be to have, in the IN clause the list of all possible subtypes of all collections mapped on the target table (‘Mecanical’, ‘Electrical’).





Regards,


Stephane


Envoyé par BlueMail<http://www.bluemail.me/r?b=14063>