관리 메뉴

ふたりで

mybatis+select count() resultType 본문

Spring

mybatis+select count() resultType

graykang 2023. 11. 27. 10:43
728x90
반응형
SMALL

Spring MVC에서 select count() 시 mybatis설정 및 resultType 참고.

- Dao 쿼리 결과를 Object로 받은 후 int로 리턴.

	public int getUserCount(userInfoVO params) {
		Object obj = selectOne("selectUserCount");
		return obj == null ? 0 : (Integer) obj;
	}

 

- mybatis에서 resultType을 Integer로 설정.

	<select id="selectUserCount" resultType="Integer">
		SELECT COUNT(*) FROM USERINFO with(nolock)
		WHERE user_code = #{userCode};
	</select>
728x90
반응형
LIST
Comments