title: Spring Data JPA - Specifications join
body: <p>I have specification:</p>
  
  <pre><code>final String text = "%text%";
  final Specifications&lt;PersonEntity&gt; spec = Specifications.where(
      (root, query, builder) -&gt; builder.like(builder.lower(root.join(PersonEntity_.addresses, JoinType.LEFT).get(AddressEntity_.addressLine1)), text)
  ).or(
      (root, query, builder) -&gt; builder.like(builder.lower(root.join(PersonEntity_.addresses, JoinType.LEFT).get(AddressEntity_.addressLine2)), text)
  ).or(
      (root, query, builder) -&gt; builder.like(builder.lower(root.join(PersonEntity_.addresses, JoinType.LEFT).get(AddressEntity_.city)), text)
  )
  </code></pre>
  
  <p>After using:</p>
  
  <pre><code>personRepository.findAll(spec);
  </code></pre>
  
  <p>In logs, I see, that JPA create a query where it joins addresses three times instead of once. </p>
  
  <p>How can I write a Specification where addresses will be joined only once? </p>