You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Mark Struberg <st...@yahoo.de.INVALID> on 2018/11/03 21:58:54 UTC

Re: OpenJPA2.3.0 - Fail to find object with multiple collection + reverse mapping of polymorphic objects + EAGER-FETCHING

 do you mind to share the entities?
LieGrue,strub

    On Friday, 2 November 2018, 12:31:20 CET, Stephane Passignat <pa...@hotmail.com> wrote:  
 
 Hello,

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,


Provenance : Courrier<https://go.microsoft.com/fwlink/?LinkId=550986> pour Windows 10