我有一个名为Profile的类及其JPA存储库ProfileRepo我正在尝试使用findBy方法使用名字或中间名或姓氏以及使用contains子句查找名称.
public class Profile{
private String firstName;
private String middleName;
private String lastName;
//getters and setters
}
Run Code Online (Sandbox Code Playgroud)
我在JPA存储库中使用以下查询但它不接受该方法
List<Profile> findByLastNameContainingOrFirstNameContainingOrMiddleNameContainingAllIgnoreCase(String firstName,
String lastName,String midName);
Run Code Online (Sandbox Code Playgroud)
请帮忙.
我正在编写一个 spring rest 方法来从数据库中获取详细信息并将其设置在响应 POJO 中,然后返回它。目前,当使用 POSTMAN 或 RC(如带有数据的可下载 CSV 文件)命中 URL 时,我需要以 CSV 格式而不是默认 json 格式生成此响应。我用谷歌搜索了很多网站,但我不确定一些逻辑。
目前我还没有为 CSV 转换编写任何代码。
@GetMapping("/batch/export" , produces="text/csv")
public ResponseEntity<ApplicationResponse> getBatchDetails(
HttpServletRequest request) {
ApplicationRequest appRequest = ApplicationServiceMapper.mapRequestFromHttpRequest(request);
ApplicationResponse response = appService.getDBDetails(appRequest);
return new ResponseEntity<>(response, HttpStatus.OK);
}
Run Code Online (Sandbox Code Playgroud)
这里的响应是服务以 pojo 格式返回所有数据的响应,如果我们不在注释中给出产品,那么默认情况下 spring 将返回响应 json。有人可以指导我吗?提前致谢。