无参数查询:
//无参的查找
@Query("select id,folderName from FolderEntity ")
public List<FolderEntity> findIdAndFolderName();
查找方法可以使用自定义findIdAndFolderName()调用,也可使用findAll()及jdk8新方法使用:
List<FolderEntity> folderList=this.folderRepository.findAll();
List<String> folderNames=folderList.stream().map(FolderEntity::getFolderName).collect(Collectors.toList());
folderNames.forEach(s -> {if(s==request.getFolderName()) {
System.out.println("文件夹名称重复");
} else{
BeanUtils.copyProperties(request, folderEntity);
}
});
有参数查询:
@Query("select id,folderName from FolderEntity where folderName=:folderName")
public List<FolderEntity> findIdAndFolderName(String folderName);