티스토리 뷰

Computer/iBatis

[iBatis] 자주 쓰는 태그들.

인생이글케쉬우냐 2010. 6. 21. 16:14
출처: http://blog.naver.com/taekwondomin?Redirect=Log&logNo=90068865546

널체크같은 경우, datetime같은 날짜형에겐 적절한 태그같다.. +_+
웹단에서 날짜포멧을 변환하는 부분에서 에러가나서 값이 없을경우 Null을 보냈더니,
xml관련되서 또 난리가 났다.


org.springframework.web.util.NestedServletException: Request processing failed; nested exception is dynamic.mrp.dao.DAException: dynamic.ibatis.util.SqlMapUtilException: com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred while applying a parameter map.  
--- Check the Tech_Repair_Center-insert-InlineParameterMap.  
--- Check the parameter mapping for the 'repairDate' property.  
--- Cause: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]The specified SQL type is not supported by this driver.
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:583)
	org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	dynamic.filter.HttpServiceContextFilter.doFilter(HttpServiceContextFilter.java:42)
	org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)


따라서 문제가 되는 부분을 Null 체크해줬더니 해당에러없이 무난히 지나갔다
	
		insert into Tech_Repair_Center(
				repairType, requesterId, requesterName, requesterPhoneNo,
				requesterEmail, requesterDeptCode, requesterDeptName, requesterDeptLocation, troubleDescription,
				repairDescription, repairStatus, operatorId, operatorName, 
				
				expectDate,
				
				
				repairDate,
				
				creatorId, creatorName, description
			) values (
				#repairType#, #requesterId#, #requesterName#, #requesterPhoneNo#,
				#requesterEmail#, #requesterDeptCode#, #requesterDeptName#, #requesterDeptLocation#, #troubleDescription#, 
				#repairDescription#, #repairStatus#, #operatorId#, #operatorName#, 
				
				#expectDate#,
				
				
				#repairDate#,
				 
				#creatorId#, #creatorName#, #description#
			)
			
			select max(idx) from Tech_Repair_Center
		
	



===============자주 쓰는 태그들 ===============
1] Alias
<typeAlias alias="asName" type="package.SampleClassName"/>

2] 기본 태그
Select : <select id="test" parameterClass="package.ClassName" resultClass="package.ClassName">
Insert : <insert id="test"  parameterClass="package.ClassName" >
Update : <update id="test"  parameterClass="package.ClassName" >
Delete : <delete  id="test"  parameterClass="package.ClassName" >
Statement : <statement  id="test"  parameterClass="package.ClassName" >

3] 프로퍼티 존재여부
존재할때 : <isPropertyAvailable property="a"></isPropertyAvailable>
존재하지 않을때  : <isNotPropertyAvailable property="a"></isNotPropertyAvailable>

4] 프로퍼티 Null 체크
Null 일때: <isNull property="a"></isNull>
Null이 아닐때: <isNotNull property="a"></isNotNull>

5] 프로퍼티 Empty 체크
Empty일때 : <isEmpty property="a"></isEmpty>
Empty아닐때 : <isNotEmpty property="a"></isNotEmpty>

6] 프로퍼티 값 비교
같을 때 : <isEqual property="a" compareValue="K"></isEqual>
같지 않을때 : <isNotEqual property="a" compareValue="K"></isNotEqual>

7] ParameerMap
<parameterMap id="paramMap" class="package.ClassName">
    <parameter property="id"/>
    <parameter property="name" javaType="java.lang.String" jdbcType="VARCHAR" mode="IN"/>
    <parameter property="msg" javaType="java.lang.String" jdbcType="VARCHAR" mode="OUT"/>
</parameterMap>

8] ResultMap
<resultMap id="reMap" class="package.ClassName">
    <result property="id" column="test_id"/>
</resultMap>

9] Dynamic
<select>
select a from test
<dynamic prepend="where">
    <isNotNull property="a"> id = #a# </isNotNull>
    <isNotNull property="b" prepend="AND"> name = #b#</isNotNull>
    <isNotNull property="c" prepend="AND"> open="(" close=")">
        <isNotNull property="c"> no = #c# </isNotNull>
        <isNotNull property="c" prepend="OR"> no_as = #d# </isNotNull>
    </isNotNull>
</dynamic>
</select>





반응형

'Computer > iBatis' 카테고리의 다른 글

[iBatis] sqlMapConfig.xml 에러  (2) 2010.05.07
[iBatis] update문에서 sqlMap의 매칭  (2) 2009.09.18
iBatis 초 간편 설정.  (0) 2009.05.14