我有一个实体 Job 如下。@Entity@Getter@Setter@NoArgsConstructor@Immutable@ToString@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})@Table(name = "JOB")public class Job extends BaseEntity implements IEntity, IDto { @Id @Column(name = "JOB_ID", unique = true, nullable = false) private Long id; @Column(name = "PRINT_JOB_ID", length = 30) private String printJobId; @OneToMany(fetch = FetchType.LAZY) @JoinColumn(name = "PRINT_JOB_ID", nullable = false, insertable = false, updatable = false) private Set<PrintFile> printFileInfos = new HashSet<PrintFile>();}我还有另一个实体 PrintFile。@Entity@Getter@Setter@NoArgsConstructor@Immutable@Table(name = "PRINT_FILE")public class PrintFile implements Serializable { @Id @Column(name = "FILE_ID", unique = true, nullable = false, length = 50) private String fileId; @Column(name = "PRINT_JOB_ID", nullable = false, length = 30) private String printJobId;}这是我的桌子。JobJOB_ID NOT NULL NUMBER PRINT_JOB_ID VARCHAR2(30) Print_FilePRINT_JOB_ID NOT NULL VARCHAR2(30) FILE_ID NOT NULL VARCHAR2(50) 尝试使用 Sprint 引导休息 API 获取作业数据时,java.sql.SQLSyntaxErrorException: ORA-01722: invalid number出现错误。所有的数据类型映射似乎都是正确的,还有什么可能出错的?编辑:当我摆脱联接时,作业实体可以毫无问题地获取。即 Job 实体中 printFileInfos 的整个声明。这让我认为问题出在 join 或 PrintFile 实体中。
1 回答
哔哔one
TA贡献1854条经验 获得超8个赞
我建议您尝试以下给定的代码。添加 referencedColumnName 属性后,它对我有用。
@OneToMany(fetch = FetchType.LAZY)
@JoinColumn(name = "PRINT_JOB_ID", referencedColumnName = "PRINT_JOB_ID", nullable = false, insertable = false, updatable = false)
private Set<PrintFile> printFileInfos = new HashSet<PrintFile>();
添加回答
举报
0/150
提交
取消