title: How to query an entity and aggregate the count onto a value object
body: <p>I am trying to create a query in JPA that will get an id and find the count on multiple columns for the given id. </p>
  
  <p>Eg I have a job, this resource can have attributes added to it. I am required to find the count of every attribute and map onto a new VO for the given job id.</p>
  
  <p>Scenario.</p>
  
  <pre><code>Job A has
      1 skillsType assigned
  
  Job B has   
      2 skillsType assigned 
  </code></pre>
  
  <p>My database structure saves the <code>jobId</code>, <code>skillType</code> and <code>skillTypeId</code>. As it is, this will give me 2 values for the id of Job B, however i need it to be one row and to give the count of the skillsType by a given type.</p>
  
  <p>I have tried to create a VO on the repository to map the values onto it, however it is not working.</p>
  
  <p>My VO has the following values, <code>jobId</code>, <code>softSkillsCount</code>, <code>technicalSkillsCount</code></p>
  
  <p>Eg Job B would be 
  jobBIdValue, 1, 1 rather than
  jobBIdValue, softSkill, skillIdSoft
  jobBIdValue, technicalSkill, skillIdTechnical</p>
  
  <p>The code that I have so far is
      <code>NamedQuery = select new packagename.myJobViewVO(jobId, countOfSoftSkills,countOfTechnicalSkils) from JobView where jobId = 123</code></p>