Announcement Announcement Module
Collapse
No announcement yet.
SqlMapClientTemplate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SqlMapClientTemplate

    I don't know if this is the correct forum to post this question - but here goes

    I have a series of tables that all have a series of columns that are used identically in a WHERE clause.

    For each I have an iBatis statement and result map

    <resultMap id=”Table1ResultMap” class=”Class1” extends=”parent-resultMap”>
    <result property=”propertyName” column=”COLUMN_NAME” />
    <result ……/>
    </resultMap>

    <select id="GetTable1" parameterClass="java.util.Map"
    resultMap="Table1ResultMap">
    SELECT * FROM Table1 WHERE <repeated where clause with arg1, arg2, etc>;
    </select>
    (The common columns are in the parent-result-map.)

    Currently I have a separate java function for each table

    public List<Class1> Table1( int arg1, int arg2, ... )
    {
    final Map<String, Object> paramMap = new HashMap<String, Object>();

    paramMap.put("arg1", arg1);
    paramMap.put("arg2", arg2);

    SqlMapClientTemplate sqlMapClientTemplate = getSqlMapClientTemplate();
    return List<Class1> sqlMapClientTemplate.queryForList("GetTable1", paramMap);
    }

    I would like have a single java function

    public List<T> getTableGeneral( int arg1, int arg2, ..., String tablename, String resultMap )
    {
    final Map<String, Object> paramMap = new HashMap<String, Object>();

    paramMap.put("tableName", tablename);
    paramMap.put("arg1", arg1);
    paramMap.put("arg2", arg2);

    SqlMapClientTemplate sqlMapClientTemplate = getSqlMapClientTemplate();
    sqlMapClientTemplate.Something_that_sets_resultmap ( resultMap );

    return (List<T>) sqlMapClientTemplate.queryForList("GetTableGeneral ", paramMap);
    }

    and iBatis statement

    <select id="GetTableGeneral" parameterClass="java.util.Map" resultMap="Overridden-dynamically-resultmap">
    SELECT * FROM $tableName$ WHERE <repeated where clause with arg1, arg2, etc>;
    </select>

    I have been looking for a way to set the name of the resultMap in the SqlMapClientTemplate
    I did not see an option in the queryForList to set the resultMap.

    Is there a way to do this?

    Thanks-
    Steve
Working...
X