JPA模糊查询(表中的某些数据)
生活随笔
收集整理的這篇文章主要介紹了
JPA模糊查询(表中的某些数据)
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
業(yè)務(wù)代碼
Controller
@GetMapping({"/task/project"})public ResponseEntity findByProjectTitle(@RequestParam(required = false, defaultValue = "") String title) {return ResponseEntity.ok(projectService.findAllByUserPidAndProjectTitleLikeAndVersionIs(getOperatorId(), title));}Service
@Transactional(readOnly = true)public List<ProjectInfoRepository.ProjectSimpleInfo> findAllByUserPidAndProjectTitleLikeAndVersionIs(String operatorId, String title) {title = StringUtils.hasText(title) ? "%" + title + "%" : "%%";return repository.findAllByUserPidAndProjectTitleLikeAndVersionIs(operatorId, title, 3, ProjectInfoRepository.ProjectSimpleInfo.class);}ProjectRepository
public interface ProjectInfoRepository extends JpaRepository<ProjectInfo, String>, JpaSpecificationExecutor<ProjectInfo>, ProjectInfoCustomRepository {<T> List<T> findAllByUserPidAndProjectTitleLikeAndVersionIs(String userPid, String projectTitle, Integer version, Class<T> type);Optional<ProjectInfo> findByPid(String pid);interface ProjectSimpleInfo {String getPid();String getProjectTitle();} }Repository
<T> List<T> findAllByUserPidAndProjectTitleLikeAndVersionIs(String userPid, String projectTitle, Integer version, Class<T> type); 與50位技術(shù)專(zhuān)家面對(duì)面20年技術(shù)見(jiàn)證,附贈(zèng)技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的JPA模糊查询(表中的某些数据)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: JPA查找数据库最新一条消息
- 下一篇: Uncaught SyntaxError