>我有一个实体作业,如下所示。
@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>();
}
我还有另一个实体打印文件。
@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;
}
这是我的表格。
Job
JOB_ID NOT NULL NUMBER
PRINT_JOB_ID VARCHAR2(30)
Print_File
PRINT_JOB_ID NOT NULL VARCHAR2(30)
FILE_ID NOT NULL VARCHAR2(50)
尝试使用冲刺启动休息 API 获取作业数据时,我收到java.sql.SQLSyntaxErrorException: ORA-01722: invalid number
错误。所有的数据映射似乎都是正确的,还有什么可能出错?
编辑:
当我摆脱连接时,Job 实体获取没有任何问题,即在 Job 实体中完整声明 printFileInfos。这让我认为问题出在联接或打印文件实体中。
我建议您尝试以下给定的代码。添加引用的列名称属性后,它对我有用。
@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>();