apache / apache/incubator-seata
oracle数据库插入数据报 "ID": 标识符无效 异常
- Dominant language
- Java
- Stars
- 26k
- Forks
- 8.8k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 4
Description
oracle项目引入seata,但由于表名比较特殊 所有的字段都是用""括起来的,引入seata后发现所有的insert语句都不能正常执行,报下面的错误,复制打印的语句到数据库也能正常执行,请问这是为什么?
```
### Cause: java.sql.SQLSyntaxErrorException: ORA-00904: "ID": 标识符无效
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00904: "ID": 标识符无效
]
org.springframework.jdbc.BadSqlGrammarException:
### Error updating database. Cause: java.sql.SQLSyntaxErrorException: ORA-00904: "ID": 标识符无效
### The error may exist in cn/ztjz/module/bankStore/mapper/FiBillReceiptengiinvoMapper.java (best guess)
### The error may involve cn.ztjz.module.bankStore.mapper.FiBillReceiptengiinvoMapper.insert-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO ZTZS_ERP2."FI_Bill_ReceiptEngiInvo" ( "Id", "ReceiptId", "Number", "Code", "Amount", "AmountNoTax", "InvoDate", "CreateUser", "CreateTime", "UpdateUser", "UpdateTime" ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
### Cause: java.sql.SQLSyntaxErrorException: ORA-00904: "ID": 标识符无效
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00904: "ID": 标识符无效
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:235) ~[spring-jdbc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) ~[spring-jdbc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:88) ~[mybatis-spring-2.0.5.jar:2.0.5]
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440) ~[mybatis-spring-2.0.5.jar:2.0.5]
at com.sun.proxy.$Proxy131.insert(Unknown Source) ~[na:na]
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:271) ~[mybatis-spring-2.0.5.jar:2.0.5]
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:60) ~[mybatis-plus-core-3.4.2.jar:3.4.2]
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148) ~[mybatis-plus-core-3.4.2.jar:3.4.2]
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89) ~[mybatis-plus-core-3.4.2.ja
```
### Ⅵ. Environment:
- JDK version : 1.8
- Seata version: 1.4.2
Contributor guide
Research direction
Start with cn.ztjz.module.bankStore.mapper.FiBillReceiptengiinvoMapper.java and the logged insert-Inline statement. Compare the SQL printed by the application with the same INSERT run directly in Oracle, then trace how Seata handles the quoted table and column names while setting parameters. Done means the reported INSERT succeeds through the application and the cause is covered by an appropriate regression check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100