one to many - JPA Query - JPQL to select parents that have ALL children with a property in a SET of values -
Text after "itemprop =" text ">
I write a JPQL query to go back to the institutions whereby there is a set of assets for all children of the company Am trying to assume. This is similar to the following question, but where more than one possible value is seen:
Here is a practical example optimized by the question above ...
I want to select those fathers who are all children who are either blonde or redhead if only one black is hairy. Father is not selected
I like the above question ...
Parent.children.haircolor) Choose p from parent ('blonde', 'redhead')
or
parent where parent.children. In all of the hair color ('Gora', 'redhead') They did not have much hope of working, but only one thing has been done so far for one attempt. .
Select parent from parent where p.children from c = 0 (select count (c) where c.haircolor is not ('blonde', 'redhead')) I really would not like to run such a counts query for every line, but I'm not seeing a better system. It does not surprise me completely because I can not think of any other way to write it in plain SQL, but I am not a guru there. Is there a more efficient way to do this?
"itemprop =" text "> Try to use more JPQL path expressions than what you look like - a collection property - you do not do this Instead, join this way:
Select PR to JN PK children's WHERE c.haircolor IN: hairColorCollection above, < Code> Parents is treated as a unit with the value of the stored value children , each of which has a valuable hair color property is : hairColorCollection is a parameter that must be set to the collection object before executing the query.
Comments
Post a Comment