postgresql - Hibernate '必须在调用 save() 之前手动分配此类的 id' 但映射的数据已经包含 id
问题描述
使用 Spring Data Rest、Hibernate ORM 和 PostgreSQL。
我正在接收上传的电子表格,其中包含来自/upload
路线的数据并将其映射到Product.class
. 当电子表格被处理并映射到我Product.class
并传递Product.class
给我时,productRepo.save(product)
我收到此错误消息
org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save():
Product.class
使用这些注释创建
@Data
@Entity
@Table(name="prd")
public class Product {
@Id
private Integer nbrSupCmbndKey;
nbr_sup_cmbnd_key
是数据库中的主键列,此数据通过上传提供给我(我不需要自动生成此字段)
如何配置休眠使其正确保存,因为Product.class
当我去执行此信息时,此信息已包含在映射中productRepo.save(Product)
?
解决方案
推荐阅读
- sql - JSONB 嵌套数组查询 - 检查属性是否存在
- asp.net - 来自路由和查询字符串的 ASP.NET Core 模型绑定
- ansible - 需要遍历包含主机名的文件并在任务中使用该值
- .net-core - 运行 Resharper CLI 检查工具时出现 RedundantNameQualifier 错误
- c++ - 在opencv中使用cv::cuda::stream对图像进行异步处理
- debugging - 从 Windows 交叉编译到 Linux 时出现错误?
- maven - liquibase-maven-plugin 无法执行目标
- mongodb - MongoDB - 多对多/少对少关系模式设计,没有查找性能问题
- docker - nginx:无法执行基于路径的路由
- python - 机器人框架 - 类型错误:relativedelta 仅区分日期时间/日期