简体   繁体   English

ORA-01722:使用Hibernate时号码无效

[英]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.

相关问题 Hibernate Map抛出 - ORA-01722:无效的数字错误 - Hibernate Map throws - ORA-01722: invalid number error ORA-01722:更新中的数字无效 - ORA-01722: invalid number exception in update 问题休眠(java.sql.SQLSyntaxErrorException:ORA-01722:无效的数字) - Issue hibernate (java.sql.SQLSyntaxErrorException: ORA-01722: invalid number) 获取ORA-01722:Spring数据查询中的数字无效 - Getting ORA-01722: invalid number in Spring Data query 错误 --&gt; java.sql.SQLSyntaxErrorException: ORA-01722: 无效号码 - ERROR --> java.sql.SQLSyntaxErrorException: ORA-01722: invalid number 在准备语句中执行 IN 子句时出现无效数字异常(ORA-01722) - invalid number exception(ORA-01722) while executing IN clause in preparedstatement 插入负数-ORA-01722 - Insert negative number - ORA-01722 获取无效数字异常:ORA-01722:在金额字段中使用十进制值执行查询时无效数字 - getting Invalid Number exception : ORA-01722: invalid number while executing query with decimal value in the amount field java.sql.SQLSyntaxErrorException:ORA-01722:number_where IN无效 - java.sql.SQLSyntaxErrorException: ORA-01722: invalid number_where IN stmt.executeUpdate()返回java.sql.SQLException:ORA-01722:无效的数字 - stmt.executeUpdate() returns java.sql.SQLException: ORA-01722: invalid number
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM