### Cause: java.sql.SQLSyntaxErrorException: ORA-01722: 无效数字

org.springframework.dao.DataIntegrityViolationException: 
### Error querying database.  Cause: java.sql.SQLSyntaxErrorException: ORA-01722: 无效数字

### The error may exist in file [C:\Users\liuhaiyun\git\OSMP-Java-Project\boco.rnop.osmp.information.microservice\target\classes\mybatis\mapper\default\common\ContractMapper.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT   a.INT_ID,   a.CONTRACT_CODE,   a.CONTRACT_NAME,   a.service_type1 service_type,   b.dic_name as SERVICE_TYPE_NAME,   a.COMPANY_ID,   a.COMPANY_NAME,   d.short_name,   a.START_TIME,   a.END_TIME,   a.AMOUNT,   a.WORKCONTENT,   a.WORKAREA,   a.SENIOR_NUMBER,   a.MIDDLE_NUMBER,   a.PRIMARY_NUMBER,   a.WORK_LOAD,   a.VEHICLE,   a.METER,   a.IMPORT_USER,   a.IMPORT_USER_NAME,   a.IMPORT_DATE,   c.dic_name as STATUS   FROM   OS_CT_INFORMATION a   left join   OS_BS_Dictionary b on   a.SERVICE_TYPE1 = b.dic_key and   b.parent_key='ServiceType'   left join OS_BS_Dictionary   c on   a.Status =   c.Dic_Key and c.Parent_Key = 'BaseStatus'   left join (SELECT to_char(b.INT_ID) as   companyId,   a.SHORT_NAME   FROM OS_BS_Company   a,OS_SC_Information b   WHERE a.INT_ID = b.COMPANY_ID   AND b.IS_USE = 1) d   on a.company_id = d.companyId   WHERE 1 = 1    and a.service_type1 = ?                          and a.int_id in (SELECT contract_id FROM    os_pr_information where region_id =?)       order by a.import_date desc
### Cause: java.sql.SQLSyntaxErrorException: ORA-01722: 无效数字

放到plsql一切正常,在mybatis里就报错,明知是类型不匹配,却怎么也找不到原因,数据库类型和实体类型都是Integer,试了好久,发现实体类字段serviceType改为String就好使了。

分析sql发现问题出在“on   a.SERVICE_TYPE1 = b.dic_key”这里,表b的字段类型是varchar2,所以oracle自动把表a的类型转为varchar2,所以实体类也必须是字符串类型

你可能感兴趣的:(java)