Question

I am trying to return list of result in Custom result class but not sure whats going wrong. Here are the details of the code -

ibatis-file.xml
....
<resultMap id="inputFile" class="com.tm.systemmanager.batch.InputFile">
    <result property="fileId" column="FILE_ID" />
    <result property="fileName" column="FILE_NAME" />
    <result property="sourceDirectory" column="SOURCE_DIRECTORY" />
    <result property="movedToDirectory" column="MOVEDTO_DIRECTORY" />
    <result property="inTime" column="IN_TIME" />
    <result property="noOfRecords" column="NO_OF_RECORDS" />
    <result property="status" column="STATUS" />
    <result property="statusDate" column="STATUS_TIME" />
    <result property="statusReason" column="STATUS_REASON" />
</resultMap>

<select id="mergeSelectDuplicateRecords" parameterClass="string"
    resultMap="inputFile" >
    SELECT FILE_NAME FROM ROU_MERGE_BATCH where FILE_NAME IN (#fileNames#)
</select>
....

Here is class which call above query with String as 'abc.txt', 'xyz.txt'..

FileAuditDaoIbatisImpl extends SqlMapClientDaoSupport implements FileAuditDao
.....

public List getMergeDuplicateFiles(String fileNames){
    List lsMergeFiles = null;
    lsMergeFiles = getSqlMapClientTemplate().queryForList("mergeSelectDuplicateRecords", fileNames);
    logger.info("List of files returned by ResultSet = "+lsMergeFiles);
    return lsMergeFiles;
}
....

I am not seeing any error/exception in the logs.

Can someone please help me out to sort out the issue. I am expecting from this code to return list of result. In oracle DB, i have all the db entries to validates this query.. but not sure whats going wrong.

Était-ce utile?

La solution

Can you please print filenames and ensure that file name doesnt have any leading/trailing white space. Also I assume you have executed this query directly in DB to make sure that you are getting the results SELECT FILE_NAME FROM ROU_MERGE_BATCH where FILE_NAME IN ('abc.txt')

Also is fileNAmes a single file name or its a comma separated string ?

EDITED Issue is with the way you are passing comma separated string for IN caluse

Refer this link for using IN clause with Ibatis:

How to use an IN clause in iBATIS?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top