title: Java 8 Streams group by function, setting nested object's variable as key and parent object as value
body: <p>I assume my question is somewhat clear from the title.</p>
  
  <p>I have two classes : <code>parent A and child B.</code>
  and want to have return like <code>Map&lt;Integer,A&gt;</code> where <code>key is a field from</code> <code>child B</code>.
  I have <code>List&lt;A&gt; aList</code> extracted from database.
  Class Definitions:</p>
  
  <pre><code>public class B {
      Integer id;
      String some;
      String some2;
  }
  
  public class A {
      Integer id;
      B someB;
      String name;
  }
  </code></pre>
  
  <p>I was trying like <code>aList.streams.collect(Collectors.groupingBy(A::getSomeB))</code> but this is not what I want.
  There is only one to one relationship between parent and child so I don't need <code>Map&lt;Integer,List&lt;A&gt;&gt; as the result</code></p>
  
  <p>I can do this by looping the <code>aList</code> but if there is a built in Java 8 function, I would like to use it.</p>