title: Springdata/JPQL -- How to put in element from list to subselect value
body: <p>Spring Data / JPQL problem
  base: posgresql 10
  backend : Java / Spring boot</p>
  
  <p>I have a very interesting problem,
  how can I insert the currently selected value from the java list used in where as the value for the subselect.</p>
  
  <p>Some pseudocode</p>
  
  <p>Data to select 
  code:</p>
  
  <p>Data for the select comes from the object</p>
  
  <pre><code>List&lt;DateForSelect&gt; listOfElements;
  
  @Data
  public class DateForSelect {
  
      private Long idDoc;    
      private Long additionalValForSelect;
  
  }
  </code></pre>
  
  <hr>
  
  <pre><code>select sp.xd, (subselect value from actual pair of element list of object "additionalValForSelect") from xx.sport sp where sp.doc_id in :idDoc
  </code></pre>
  
  <p>any ideas for solving this problem without FUTURE PROCESSING IN JAVA</p>
  
  <p>I will add that I know how to mapp this query this later. I am just wondering how you can eventually pull out the current value of the idDoc element and associate it with additionalValForSelect as the value of the subselect.</p>
  
  <pre><code>Synature of sql init repository method : 
  List&lt;CustomMapp&gt; searchXD(
        @Param("idDoc") Collection&lt;Long&gt; num);
  </code></pre>
  
  <p>is it possible in jpqlu in the form of subselect. Non-JPQL solutions are not interesting, eg Native Query.</p>
  
  <p>if you have interesting ideas without code examples, please give inspiration: D</p>
  
  <p>pseudo sql code:</p>
  
  <pre><code>SELECT p.sth,'additionalValForSelect[0]' as tmp FROM  schemat.tabelka p where p.id= 'idDoc[0]'
  union 
  SELECT p.sth,'additionalValForSelect[1]'   FROM  schemat.tabelka p where p.id= 'idDoc[1]'
  union 
  SELECT p.sth,'additionalValForSelect[2]'   FROM  schemat.tabelka p where p.id= 'idDoc[2]'
  union 
  SELECT p.sth,'additionalValForSelect[3]'   FROM  schemat.tabelka p WHERE p.id= 'idDoc[3]'
  
  
  for ..... loop ...
  </code></pre>
  
  <p>number of unions = listOfElements.size (its still pseudocode)</p>