当前位置: 首页 > 知识库问答 >
问题:

在jpa spring boot中有没有按列获取数据的方法

能远
2023-03-14

这是我的控制器代码

@GetMapping("/customerWasteRequest/{customer}")
public List<CustomerWasteRequest> getCustomerWasteRequest(@PathVariable String customer) {
    return service.fetchWasteRequestByCustomer(customer);
}
public class CustomerWasteRequestService{
    @Autowired

    private CustomerWasteRequestRepository repo;

    public List<CustomerWasteRequest> fetchWasteRequestByCustomer(String customer) {
                return repo.findByCustomer(customer);
    }
}
@Repository
public interface CustomerWasteRequestRepository extends JpaRepository<CustomerWasteRequest, Integer> {

    public List<CustomerWasteRequest> findByCustomer(String customer);
}
private baseUrl = 'http://localhost:8080/customerWasteRequest';

 getCustomerWasteRequests(customer:string) : Observable<any>{
    return this.http.get(`${this.baseUrl}/${customer}`);  
  }

{“cause”:{“cause”:null,“message”:“对于输入字符串:”newcustomer“},”message“:”未能从类型[java.lang.string]转换为类型[java.lang.integer]以表示值为“newcustomer”;嵌套异常是java.lang.NumberFormatException:对于输入字符串:“newcustomer”}

在http://localhost:8080/customerwasterequests/newcustomer中

共有1个答案

尉迟越
2023-03-14

“无法将值为”NewCustomer“的[java.lang.String]类型转换为[java.lang.Integer]类型

您的属性customerinto实体customerwasterequest是否具有类型integer而不是string

 类似资料:
  • 问题内容: 我有一个视图vwGetData,它从两个表t1,t2中获取数据并具有字段: 我将在下面提供输入 我想在C#/ SQL中获得以下输出 或者 我想使用C#和SQL做到这一点。 问题答案: 您要做的第一件事是确保没有数据被返回: 现在假设您知道如何设置一个DataReader,您将执行以下操作: 您也可以查看SQL Catalog SYS视图。

  • 问题内容: 我想从数据库中的表中获取列名列表。使用编译指示,我会得到一个元组列表,其中包含很多不需要的信息。有没有办法只获取列名?所以我最终可能会遇到这样的事情: [Column1,Column2,Column3,Column4] 之所以绝对需要此列表,是因为我想在列表中搜索列名并获取索引,因为很多代码中都使用了索引。 有没有办法得到这样的清单? 谢谢 问题答案: 您可以使用sqlite3和pep

  • 我想在应用GROUPBY条件后取消对数据帧的分组。我一组一组地用熊猫 现在我想将数据解组。列名是由下划线连接的列的组合。例如:Amt\u 8\u red\u 17:列名是(Amount、Count、Color、Id)输出的样子 有没有更快的办法?

  • 问题内容: 我试图找到一种方法来查找数据库中的表的名称(如果存在)。我发现从sqlite cli我可以使用: 然后对于字段: 这显然在python中不起作用。有没有办法用python做到这一点,还是我应该只使用sqlite命令行? 问题答案: 您应该能够从表中访问表名称。 列名不能直接访问。获取它们的最简单方法是查询表并从查询结果中获取列名。

  • 我已经看到,这在其他类型的对话框窗口中是可能的,如“ShowConfirmDialog”,其中可以指定按钮的数量和它们的名称;但是在使用“ShowInputDialog”时是否可以实现相同的功能?我似乎在API中找不到这种类型的东西。也许我只是错过了,但任何帮助都很感激。

  • 我是一个ETL过程,我正在从Spring数据存储库中检索大量实体。然后使用并行流将实体映射到不同的实体。我可以使用一个使用者将这些新实体逐个存储在另一个存储库中,或者将它们收集到一个列表中,并将其存储在单个批量操作中。第一种方法代价很高,而后者可能会超出可用的内存。