title: How can I write SQL query in JPA repository with Spring Boot?
body: <p>I'm doing a spring boot experiment and using MySQL.</p>
  <p>For example, if I have a list of users, but I want to get the specified names, how can I write the SQL query that only indicates this situation?</p>
  <p>This is my model class :</p>
  <pre><code>@Getter
  @Setter
  @NoArgsConstructor
  @AllArgsConstructor
  @Entity
  @Table(name=&quot;users&quot;)
  public class User {
      
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      public long id;
      
      @Column(name=&quot;first_name&quot;)
      public String name;
      
      @Column (name=&quot;last_name&quot;)
      public String last_name;
  }
  </code></pre>
  <p>This is my JPA interface :</p>
  <pre><code>public interface CommentRepository extends JpaRepository&lt;User , Long &gt;{
  
    // All C.R.U.D database methods
  }
  </code></pre>
  <p>Finally, my controller area is as below :</p>
  <pre><code>@RestController
  @RequestMapping(path=&quot;/api/v1/users&quot;)
  public class CommentController {
      
      @Autowired
      CommentRepository repository ;
      
      @GetMapping(path=&quot;/list&quot;)
      public List&lt;User&gt; users() {
          
          return repository.findAll();
      }  
  }
  </code></pre>
  <p>Maybe you didn't understand my problem, I just want to write a customizable query of my own.</p>
  <p>For example, I want to pull the data with the method I designed, while I normally pull the data by numbers with the find by id method.</p>