spring - 使用 JPA 查询时未显示响应正文
问题描述
我正在尝试使用 jpa 查询方法显示特定的实体数据,以通过它们的“Nome”参数和升序和降序的顺序找到它们。
我正在使用以下查询方法:
public List<Cliente> findByNomeOrderByNomeAsc(String nome);
public List<Cliente> findByNomeOrderByNomeDesc(String nome);
我的控制器代码是:
@ApiImplicitParam(name = "Authorization", value = "Bearer Token", required = true,
allowEmptyValue = false, paramType = "header", example = "Bearer access_token")
@ApiOperation("Listar todos os clientes por nome em ordem crescente")
@GetMapping("/nome/asc/{nome}")
public List<Cliente> listarPorNomeOrdemCrescente(@PathVariable String nome) {
return clienteRepository.findByNomeOrderByNomeAsc(nome);
}
@ApiImplicitParam(name = "Authorization", value = "Bearer Token", required = true,
allowEmptyValue = false, paramType = "header", example = "Bearer access_token")
@ApiOperation("Listar todos os clientes por nome em ordem decrescente")
@GetMapping("/nome/desc/{nome}")
public List<Cliente> listarPorNomeOrdemDecrescente(@PathVariable String nome) {
return clienteRepository.findByNomeOrderByNomeDesc(nome);
}
出于某种原因,我得到一个空向量作为响应,这意味着列表是空的。
客户实体:
@Entity
@ApiModel(value = "Cliente", description = "Representa um cliente")
@Table(name = "cliente")
public class Cliente {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NotNull
private String nome;
@NotNull
private String email;
@NotNull
private String senha;
@NotNull
private String documento;
@NotNull
private Date dataCadastro;
//getters and setters
}
如果有人能帮我解决这个问题,我将不胜感激。谢谢你。
解决方案
推荐阅读
- c# - 子窗体上的 C# ComboBox 未更新
- c - wasm 是否支持对 USB 进行读/写?
- html - 在地理自动完成中提交表单点击功能错误
- node.js - 在 AWS Cognito 中管理用户
- r - xtable 输出看起来不像表格
- c# - C#如何连接2个MP4文件
- javascript - 上传单个文件时,Multer 返回 req.file 未定义
- ubuntu-16.04 - 目标“.build_release/src/caffe/test/test_power_layer.o”的配方失败
- c# - 当项目在 MVVM/MVW 中发生更改时,如何禁用 ListView 选择更改?
- r - 在没有 for 循环的情况下实现有效的基于条件的数据映射?