title: OneToMany LazyInitializationException when collection is empty
body: <p>I know there are dozens of questions with the same topic but I cannot figure it out why they are not working in my case.</p>
  
  <p>I have two tables, one with the name of Account and one with CustomerRelations, and there is a one-to-many relarionship between them (to one account can belong several customerRelations... an account can exist without other customer relations but a customer relation can only be attached to an existing account)</p>
  
  <p>This is how they are annotated in my entity classes:</p>
  
  <p>Account table:</p>
  
  <pre><code>@OneToMany(mappedBy = "account", cascade = CascadeType.ALL, orphanRemoval = true)
  @OnDelete(action = OnDeleteAction.CASCADE)
  private List&lt;CustomRel&gt; customRels = new ArrayList&lt;&gt;();
  </code></pre>
  
  <p>CustomerRelation table:</p>
  
  <pre><code>@ManyToOne(fetch = FetchType.EAGER)
  private Account account;
  </code></pre>
  
  <p>I have the business logic where I want to call a query based on specific date saved in the Account tabel:</p>
  
  <pre><code>@NamedQuery(name = Account.FIND_BY_ACC_NBR, query = "select acc from Account acc where acc.accountNumber =:accountNumber")
  </code></pre>
  
  <p>This query gives the correct data from the account table but for the field customerRels I get the following exception:</p>
  
  <pre><code>**Unable to evaluate the expression Method threw 'org.hibernate.LazyInitializationException' exception.**
  </code></pre>
  
  <p>The same comes when a getter method is called on my Account object:</p>
  
  <p><a href="https://i.stack.imgur.com/AfAox.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AfAox.png" alt="enter image description here"></a></p>
  
  <p>In my example case, there is an account object with an empty list of customerRels. So there is no customerRels record in the database which is connected to the accountId.</p>
  
  <p>As far as I know that the fetchType in my Account entity class in lazy - as default, right?.</p>
  
  <p>In my SQL scripts which are creating the tables, there is only an account_id added in the CustomerRelations table, in the Account table there is no reference to the child object.</p>
  
  <p>I know it is a very banal issue, but I need some help. Should I modify my JPQL query?</p>