title: How to convert SessionFactory query to JPA query?
body: <p>I am converting a plain Spring application to Spring with SpringBoot.</p>
  <p>There are some places in the code where they have queries using SessionFactory:</p>
  <pre><code>public List&lt;Enrollment&gt; findByOrganizationAndYear(Organization organization, int year) {
  
      String queryString = &quot;from Enrollment as enrollment where enrollment.organization.id = :organizationId AND YEAR(enrollment.event.fromDate) = :year&quot;;
      Query query = sessionFactory.getCurrentSession().createQuery(queryString);
      query.setParameter(&quot;organizationId&quot;, organization.getId());
      query.setParameter(&quot;year&quot;, year);
  
      return query.list();
  
  }
  </code></pre>
  <p>How can i convert this to a plain JPA query ? Or do i need to write a custom @Query ?</p>
  <p>Thank you.</p>