I am trying to pass multiple values in a SELECT QUERY consisting of an IN clause. I would like to execute the following query using mybatis:
SELECT * FROM DBA_COMPARISON_ROW_DIF WHERE SCAN_ID in (#{childScanIDs})
where the childScanIDs
variable consists of multiple comma separated values. I am passing these values as a String consisting of all the values separated with a comma. Below is the method being used in the mapper interface.
@Select(getDifferencesByScanIDs)
@Results({
@Result(property="owner", column="OWNER"),
@Result(property="comparisonName", column="COMPARISON_NAME"),
@Result(property="scanID", column="SCAN_ID"),
@Result(property="localRowID", column="LOCAL_ROWID"),
@Result(property="remoteRowID", column="REMOTE_ROWID"),
@Result(property="indexValue", column="INDEX_VALUE"),
@Result(property="status", column="STATUS"),
@Result(property="lastUpdateTime", column="LAST_UPDATE_TIME")
})
List<Difference> getDifferencesByScanIDs(@Param("childScanIDs") String childScanIDs);
I am constructing the string of values this way:
String scanIDs = StringUtils.join(cmp.getChildScanIDs(), ",");
When executing the function, it is raising this exception.
### Error querying database. Cause: java.sql.SQLSyntaxErrorException: ORA-01722: invalid number
### The error may involve com.rs2.automation.soacomparison.dao.differences.DifferencesMapper.getDifferencesByScanIDs-Inline
### The error occurred while setting parameters
### Cause: java.sql.SQLSyntaxErrorException: ORA-01722: invalid number
Any help would be appreciated. I think the problem is that mybatis is not recognizing the values as separate numbers. Another solution would be to execute the query on each number but I wanted to pass all the values at once. Thanks in advance.