How to do a complex LEFT JOIN FETCH condition in JPQL? [message #1717235] |
Thu, 10 December 2015 16:56  |
Eclipse User |
|
|
|
I'm a very simple question that I'm not able to solve, how can I make a named Query using left join fetch to load only the children who are in a condition?
I'm using eclipselink (JPQL) and JPA 2.x:
This is my named Query:
SELECT step
FROM StepEntity step
left join fetch step.precedentsSteps precedentStep
ON precedentStep.isCondition = :isCondition
and precedentStep.id.stepCode = :stepCode
and precedentStep.id.country = :country
and precedentStep.id.stageCode = :stageCode
WHERE step.id.stepCode = :stepCode
AND step.id.country = :country
and step.id.stageCode = :stageCode
step.precedentsSteps is a @OneToMany(targetEntity=PrecedentStepEntity.class, fetch=FetchType.LAZY, mappedBy = "step")
When I use the left join fetch it is bringing all the children that are in the Step entity and I just want it load the collection on the condition = true;
I am very grateful for the help already
|
|
|
|
Powered by
FUDForum. Page generated in 0.03031 seconds