/** * 查询还没生成索引的帖子 * @return */ @Query(value = "SELECT * FROM t_article WHERE index_state=0",nativeQuery = true) public List<Article> getArticleNoIndex(); /** * 更改索引为true */ @Transactional @Modifying @Query(value = "UPDATE t_article SET index_state = TRUE WHERE id =?1",nativeQuery = true) public void updateArticleIndex(Integer id); 简单例子: @Query(value = "select name,author,price from Book b where b.price>?1 and b.price<?2") List<Book> findByPriceRange(long price1, long price2); Like表达式: @Query(value = "select name,author,price from Book b where b.name like %:name%") List<Book> findByNameMatch(