###前提・実現したいこと
MyBatis で自作したクエリを実行して Integer型で返り値を受けたい
###発生している問題・エラーメッセージ
DB検索結果が null になってしまう
###ビジネスロジック
Integer amount = tqmapper.selectSumAnswer("amount", 1); // ↑ここが null で返ってきてしまう
###mapper interface 内
Integer selectSumAnswer(@Param("category2") String category2, @Param("t_user_id") Integer t_user_id);
###mapper.xml
<select id="selectSumAnswer" resultMap="BaseResultMap" parameterType="java.lang.Integer"> select sum(answer) from t_mental_q inner join t_mental_a ON t_mental_q.id = t_mental_a.t_mental_q_id where category2 = 'amount' and t_user_id= 1 and t_mental_a.created between '2015-10-17' and '2015-11-24'; </select>
###実際投げているクエリログ
select sum(answer) from t_mental_q inner join t_mental_a ON t_mental_q.id = t_mental_a.t_mental_q_id where category2 = 'amount' and t_user_id= 1 and t_mental_a.created between '2015-10-17' and '2015-11-24'
###補足情報(言語/FW/ツール等のバージョンなど)
Mybatis 3.3.0
MySQL 5.6
Spring Boot 1.2.1
Java SE8
どなたかお知恵をお借りできれば幸いです。よろしくお願いいたします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/11/21 04:24 編集