title: Iterate through a repository to access certain information
body: <p>In my Java/Spring application I am trying to iterate through all items found in the SQL Database Table called License, and send an email if the licence expiration date is 30 days away from today, but I am having issues iterating through. </p>
  
  <p>The issue is accessing the expiration column. What should I be doing to access the expiration date of each license in the database, because clearly the way I am doing it is not accurate. I might be getting confused because you need to get all the items from the table through the repository but then for each item you use the model to get access the Expiration date. </p>
  
  <p>Is there a better way to iterate through the list of items in a repository and access specific columns? Or can someone easily help me fix the code I have so far?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>List&lt;License&gt; licenses=licenseRepository.findAll();
  for(Object lic:licenses){
  
      if (lic.expiration.minusDays(30) == LocalDate.now()) {
          try {
              emailService.sendSimpleMessage(mail, licenseModel);
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  }</code></pre>
  </div>
  </div>
  </p>