[英]ORA-01722: invalid number when using Hibernate
I have an entity Job as below. 我有一个实体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>();
}
I also have another entity 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;
}
Here are my tables. 这是我的桌子。
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)
When trying fetch Job data using Sprint boot rest API, I'm getting java.sql.SQLSyntaxErrorException: ORA-01722: invalid number
error. 尝试使用Sprint引导休息API提取作业数据时,出现java.sql.SQLSyntaxErrorException: ORA-01722: invalid number
错误。 All the dataype mapping seems to be correct, what else could have gone wrong ? 所有的数据类型映射似乎都是正确的,还有什么可能出错了?
EDIT: 编辑:
The Job entity fetches without any issues when I get rid of the join. 当摆脱连接时,Job实体将毫无问题地获取。 ie, the entire declaration of printFileInfos in Job entity. 即Job实体中printFileInfos的整个声明。 This makes me think the issue is either with the join or in PrintFile entity. 这使我认为问题出在联接或PrintFile实体中。
I would recommend you to try below given code. 我建议您尝试使用以下给定的代码。 After adding referencedColumnName attribute, it worked for me. 添加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>();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.