title: Spring JPA: Why is my list of users empty?
body: <p>H2  TABLE: <code>USERS</code></p>
  <pre><code> | USER_ID | USER_NAME | USER_PASSWORD | USER_RIGHTS |  
   -----------------------------------------------------
   |    1    |  rooter   |     123456    |    ROOT     |  
  </code></pre>
  <pre class="lang-java prettyprint-override"><code>@Entity
  @Getter
  @Setter
  @Table(name = &quot;USERS&quot;)
  public class User {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = &quot;user_id&quot;)
      private Long userId;
      @Column(name = &quot;user_name&quot;)
      private String userName;
      @Column(name = &quot;user_password&quot;)
      private String userPassword;
      @Column(name = &quot;user_rights&quot;)
      private String userRights;
      // equals() and toString()
  }
  </code></pre>
  <pre class="lang-java prettyprint-override"><code>public interface UserRepository extends JpaRepository&lt;User, Long&gt; {
      User findByUserName(String userName);
      User findByUserId(Long id);
  }
  </code></pre>
  <pre class="lang-java prettyprint-override"><code>@RestController
  @RequestMapping(&quot;/user&quot;)
  public class UsersApi {
      private final UserRepository userRepository;
  
      public UsersApi(UserRepository userRepository) {
          this.userRepository = userRepository;
      }
  
      @GetMapping(&quot;/test&quot;)
      public List&lt;User&gt; test(String name, Long id) {
          List&lt;User&gt; response = new LinkedList&lt;&gt;();
          response.add(userRepository.findByUserName(name));
          response.add(userRepository.findByUserId(id));
          return response;
      }
  }
  </code></pre>
  <p>When I visit <code>/user/test?name=rooter&amp;id=1</code> it will response with:</p>
  <pre class="lang-json prettyprint-override"><code>[
      null,
      {
          &quot;userId&quot;:1,
          &quot;userName&quot;:&quot;root&quot;,
          &quot;userPassword&quot;:&quot;123456&quot;,
          &quot;userRights&quot;:&quot;ROOTER&quot;
      }
  ]
  </code></pre>
  <p>Why the method <code>findByUserName(String userName)</code> cannot find the data?</p>