ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sathish S <flex2...@gmail.com>
Subject Reg queryForList (returns back a list of empty objects)
Date Thu, 01 Dec 2005 10:56:15 GMT
Hi All,
    I wanted to query an unknown table at the runtime ie the user will
select a table from the list of tables (These tables are created dynamically
at the runtime and I am not sure about the table definition) and would like
to see the records. I am using the method queryForList("statementName",
tableNameParameter). But the list that this method returns back is a list of
empty objects (even though the size of the list is equal to the number of
records available in the table). Though queryForMap returns me the data, I
cannot use queryForMap because I am not sure about the columnName that can
be used for keyParameter (I might not get all the records if that columnName
has duplicate values as the records might get overwritten in the Map). I
have attached my sample code and output in this mail.
    Can anyone tell me what's wrong in my code or any workaround? I am using
iBatis version 2.1.5 GA.

SQLMap:
--------------
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE sqlMap
    PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
    "http://ibatis.apache.org/dtd/sql-map-2.dtd">

<sqlMap namespace="MultiSiteDataCompare">

  <select id="getDataList" resultClass="java.util.List"
parameterClass="string">
    Select * from $value$
  </select>
</sqlMap>


Code:
---------
    public List fetchData(String tableName) throws SomeCustomException
    {
        logger.debug("Before Execution");
        List list = queryForList("getDataList", tableName);
        logger.debug("After Execution");
        logger.debug("Result -> " + list.toString());
        return list;
    }


O/P:
-------
2005-12-01 16:12:29,714 DEBUG [
com.aspect.eds.dao.datamap.DataCompareSqlMapDao] - Before Execution (
DataCompareSqlMapDao.java:fetchData:38)
2005-12-01 16:12:29,792 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] -
Created connection 2868213. (Log4jImpl.java:debug:22)
2005-12-01 16:12:29,792 DEBUG [java.sql.Connection] - {conn-100005}
Connection (Log4jImpl.java:debug:22)
2005-12-01 16:12:29,792 DEBUG [java.sql.PreparedStatement] - {pstm-100006}
PreparedStatement:      Select * from resource..Server    (
Log4jImpl.java:debug:22)
2005-12-01 16:12:29,792 DEBUG [java.sql.PreparedStatement] - {pstm-100006}
Parameters: [] (Log4jImpl.java:debug:22)
2005-12-01 16:12:29,792 DEBUG [java.sql.PreparedStatement] - {pstm-100006}
Types: [] (Log4jImpl.java:debug:22)
2005-12-01 16:12:29,807 DEBUG [java.sql.ResultSet] - {rset-100007} ResultSet
(Log4jImpl.java:debug:22)
2005-12-01 16:12:29,807 DEBUG [
com.aspect.eds.dao.datamap.DataCompareSqlMapDao] - After Execution (
DataCompareSqlMapDao.java:fetchData:40)
2005-12-01 16:12:29,807 DEBUG [
com.aspect.eds.dao.datamap.DataCompareSqlMapDao] - Result -> [[], [], [],
[], [], [], [], []] (DataCompareSqlMapDao.java:fetchData:41)
2005-12-01 16:12:29,839 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] -
Returned connection 2868213 to pool. (Log4jImpl.java:debug:22)



--
Thanks,
Sathish S

Mime
View raw message