title: JPA Left joining multiple OneToMany entities
body: <p>HI I am trying to make a Order tracking system for the company I am working for.</p>
  
  <p>Currently I need to load PO entites from my mySQL database on start up that have invoices that are either null or not 'DELIVERED' status(enum).</p>
  
  <h2>My entites are as follows</h2>
  
  <pre><code>@Entity
  public class PO {
  
  @Id
  @GeneratedValue
  private Long id;
  
  @Column(name = "Customer", nullable = false)    
  private String customer;
  
  @Column(name = "PO_number", nullable = false)
  private String PONUMBER;
  
  @OneToMany(mappedBy = "po",cascade = CascadeType.PERSIST,fetch = FetchType.EAGER)
  private  List&lt;CatogeryEntires&gt; poCatogories = new ArrayList&lt;&gt;();
  
  @Column(name = "entered_on", nullable = false)
  private LocalDateTime entryDate;
  
  @Column(name = "Delivery_Date", nullable = false)
  private LocalDate dd;
  
  @Transient
  private ObjectProperty&lt;LocalDate&gt; deliveryDate;
  
  @Column(name = "Deliver_Before", nullable = false)
  private LocalTime dt;
  
  @Transient
  private ObjectProperty&lt;LocalTime&gt; deliveryTime;
  </code></pre>
  
  <hr>
  
  <pre><code>@Entity
  public class CatogeryEntires {
  
   @Id
      @GeneratedValue
      private Long id;
  
      @Enumerated(EnumType.STRING)
      private PO_CATOGERY poCatogery;
  
      @ManyToOne
      @JoinColumn(name = "po_id", nullable = false)
      private PO po;
  
      @OneToMany(mappedBy = "catogeryEntries", cascade = CascadeType.PERSIST)
      private Set&lt;Invoice&gt; invoices = new HashSet&lt;&gt;();
  </code></pre>
  
  <hr>
  
  <pre><code>@Entity
  public class Invoice {
  
  @Id
  @GeneratedValue
  private Long id;
  
  private int invoiceNumber;
  
  @Column(name = "delivered_on", nullable = true)
  private LocalDateTime deliveredOn;
  
  @Enumerated(EnumType.STRING)
  @Column(name = "status", nullable = true)
  private InvoiceStatus invoiceStatus;
  
  @ManyToOne
  @JoinColumn(name = "catogery_entry_id")
  private CatogeryEntires catogeryEntries;
  </code></pre>
  
  <hr>
  
  <p>I currently use the following native SQL statement in my data base to get the desired results</p>
  
  <p><strong>SELECT</strong> po_app.po.id,Customer,PO_number,Delivery_Date,Deliver_Before
  ,poCatogery,invoiceNumber,status</p>
  
  <p><strong>FROM</strong> (po_app.po left join po_app.catogeryentires on po.id = catogeryentires.po_id)</p>
  
  <p><strong>LEFT JOIN</strong> po_app.invoice on catogeryentires.id = invoice.catogery_entry_id</p>
  
  <p><strong>WHERE</strong> status is null or status != 'DELIVERED';</p>
  
  <p>and I do not know to replicate this via JPQL
  I try reading reference books like: Java persistance and hibernate 2nd editions" and still no luck.</p>