Search code examples
javamysqlsqlibatis

How to get the output of a sql count query using ibatis?


How can I get count of record from a particular column.

getSqlMapClientTemplate().queryForObject(IS_EXIST_RECORD_ASSIGNMENT_TRANS_MASTER_TABLE, reportId); 

The query I have used is as follows

SELECT Count(report_id) 
FROM   (SELECT report_id 
        FROM   m_assign_reports 
        UNION 
        SELECT report_id 
        FROM   m_assign_reports_trans) 
WHERE  report_id = #reportid# 

Solution

  • resultClass declaration is mandatory. Below is the reference for the alias available for Java types ALias reference for IBatis