<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.microservices.dss.projects.mapper.JournalsMapper">
    <resultMap id="BaseResultMap" type="com.microservices.dss.projects.domain.Journals" >
        <id column="id" property="id" jdbcType="INTEGER" />
        <result column="journalized_id" property="journalizedId" jdbcType="INTEGER" />
        <result column="journalized_type" property="journalizedType" jdbcType="VARCHAR" />
        <result column="user_id" property="userId" jdbcType="INTEGER" />
        <result column="notes" property="notes" jdbcType="VARCHAR" />
        <result column="created_on" property="createdOn" jdbcType="TIMESTAMP" />
        <result column="private_notes" property="privateNotes" jdbcType="BIT" />
        <result column="parent_id" property="parentId" jdbcType="INTEGER" />
        <result column="comments_count" property="commentsCount" jdbcType="INTEGER" />
        <result column="reply_id" property="replyId" jdbcType="INTEGER" />
        <result column="review_id" property="reviewId" jdbcType="BIGINT" />
        <result column="commit_id" property="commitId" jdbcType="VARCHAR" />
        <result column="line_code" property="lineCode" jdbcType="VARCHAR" />
        <result column="path" property="path" jdbcType="VARCHAR" />
        <result column="state" property="state" jdbcType="INTEGER" />
        <result column="resolve_at" property="resolveAt" jdbcType="TIMESTAMP" />
        <result column="resolveer_id" property="resolveerId" jdbcType="INTEGER" />
        <result column="need_respond" property="needRespond" jdbcType="BIT" />
        <result column="updated_on" property="updatedOn" jdbcType="TIMESTAMP" />
    </resultMap>

    <select id="getNewJournalsNumByMonth" parameterType="java.lang.String" resultType="java.util.HashMap">
        SELECT
            DATE_FORMAT(created_on, '%Y-%m') AS createTime,
            COUNT(*) AS num
        FROM
            journals
        WHERE
            created_on &gt;= #{startTime,jdbcType=VARCHAR}
          AND created_on &lt;= #{endTime,jdbcType=VARCHAR}
        GROUP BY DATE_FORMAT(created_on, '%Y-%m')
    </select>
</mapper>