title: Cannot resolve method 'getName' in 'Optional'
body: <p>I would like to get the value of my database with the getter <code>getName()</code>.
  First, I have created User.java:</p>
  <pre><code>package ch.concertopro.webshopanalyser.entity;
  
  import javax.persistence.*;
  
  @Entity(name = &quot;users&quot;)
  public class User {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private int id;
      private String name;
      @Column(unique = true, nullable = false)
      private String email;
      private String dob;
  
  
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public String getDob() {
          return dob;
      }
  
      public void setDob(String dob) {
          this.dob = dob;
      }
  }
  
  </code></pre>
  <p>Then I have created UserRepository.java:</p>
  <pre class="lang-java prettyprint-override"><code>package ch.concertopro.webshopanalyser.repository;
  
  import ch.concertopro.webshopanalyser.entity.User;
  import org.springframework.data.repository.CrudRepository;
  import org.springframework.stereotype.Repository;
  
  @Repository
  public interface UserRepository extends CrudRepository&lt;User, Integer&gt; {
  
  }
  </code></pre>
  <p>And this is my service where I try to get the value of <code>getName()</code>:</p>
  <pre class="lang-java prettyprint-override"><code>package ch.concertopro.webshopanalyser.service;
  
  import ch.concertopro.webshopanalyser.entity.User;
  import ch.concertopro.webshopanalyser.repository.UserRepository;
  import org.springframework.stereotype.Service;
  
  @Service
  public class UserService {
  final UserRepository userRepository;
  
      public UserService(UserRepository userRepository) {
          this.userRepository = userRepository;
      }
  
      public Iterable&lt;User&gt; getUser() {
          return userRepository.findById(1).getName();
      }
  }
  </code></pre>
  <p>But I get the error <em>Cannot resolve method 'getName' in 'Optional'</em>. Why?</p>