简体   繁体   English

获取ORA-01722:Spring数据查询中的数字无效

[英]Getting ORA-01722: invalid number in Spring Data query

I have two tables joined by non primary keys. 我有两个由非主键连接的表。 This SQL query outputs 3 values as expected. 该SQL查询将按预期输出3个值。

Its looking for the primary key of Department table. 它正在寻找Department表的主键。 department2_.deptno Therefore I will try @EmbeddedId. department2_.deptno因此,我将尝试@EmbeddedId。

Try the following in the Where statement: Where语句中尝试以下操作:

employee.emp_dept_code In(employee.department)

Update 更新

you are trying to compare a number to varchar2 in where statement. 您正在尝试在where语句中将数字与varchar2进行比较。

If you are on UNIX/ LINUX operating system, then the table names in MySQL are case sensitive. 如果您使用UNIX / LINUX操作系统,则MySQL中的表名区分大小写。

So I always recommend to have lower case table name for @Table(name = "<your_table>") and create table with lowercase letters in create query. 因此,我始终建议为@Table(name = "<your_table>")使用小写的表名,并在create query中使用小写字母创建表。 Idea is to be consistent if your company have guidelines. 如果贵公司有指导原则,则想法应保持一致。

You can also make MySQL case insensitive follow this tutorial 您还可以使MySQL不区分大小写,请按照本教程进行操作

该表没有主ID,因此我使用ROWID作为主键,并且可以正常工作。JPA实体没有主键?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM