道路环境监测node后端和java后台代码
wangrong
2021-11-24 ac1a5f4542431c28b5865acbeb81985cefdbc2a8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.example.demo.dao;
 
import com.example.demo.model.Article;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
 
import java.util.List;
 
/**
 * 直接继承 JpaRepository 就有了增删改查等能力,该功能由 spring-data-jpa 提供
 * 泛型说明:Article 实体类对象  Long 主键数据类型
 *
 * @author liyuepeng
 * @date 2021/1/6 18:31
 */
public interface ArticleRepository extends JpaRepository<Article, Long> {
 
    //方法名称必须要遵循驼峰式命名规则,findBy(关键字)+属性名称(首字母大写)+查询条件(首字母大写)
    List<Article> findByTitle(String title); //根据标题查找文章
 
    List<Article> findByTitleLike(String title);
 
    @Query("from Article where top = true")
    List<Article> queryByHql(String name);
 
}