SpringBoot Jpa 自定义查询


SpringBoot Jpa 自定义查询

持久层Domain

public interface BaomingDao extends JpaRepository<BaomingBean,Integer> {
    
    @Query(value = "select distinct t.actid from BaomingBean t where t.belongs=?1")
    List<String> findDistinctActid(String belongs);
    //自定义SQL 语句根据belongs查询所有的actid 且去重 from + 实体类名称(非表名) actid 和 belongs 都是Bean中的属性,而非数据库字段名
}

控制器写法

@RequestMapping(value = "*")
public List<String> findDistinctSwiperName(@RequestParam("belongs") String belongs){
     return baomingDao.findDistinctActid(belongs);
}

需要各种开发请联系QQ 1025584691


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM